2017-03-15 70 views
0

我想用一个域来映射不同的项目。nginx一个域名和多个项目设置别名

mydomain.com.tw =>的/ var/WWW/PROJECT1 /公共
mydomain.com.tw/test =>的/ var/WWW /项目2

mydomain.com.tw/project2/详细总是直接到mydomain.com.tw项目路线。

PROJECT1 => laravel
项目2 => VUE和使用VUE路由

listen 80; 
listen [::]:80; 

server_name mydomain.dev; 

index index.php index.html index.htm; 
root /var/www/project1/public; 

location/{ 
    try_files $uri $uri/ /index.php$is_args$args; 
} 

location /lottery { 
    alias /var/www/project2/dist; 
    try_files $uri $uri/ @rewrites; 
} 

location @rewrites { 
    rewrite ^(.+)$ /index.html last; 
} 

location ~ \.php$ { 
    try_files $uri /index.php =404; 
    fastcgi_pass php-upstream; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
} 

location ~ /\.ht { 
    deny all; 
} 
+0

你可以使用一个子呢? (mydomain.dev和project2.mydomain.dev)。 – Lucas

+0

@Lucas不,因为需要使用相同的本地存储项目。 –

+0

您是否尝试过使用其他浏览器或清除浏览器的DNS缓存?有时这发生在我身上。 – Lucas

回答