【发布时间】:2017-08-05 18:15:23
【问题描述】:
我想使用一个域来映射不同的项目。
mydomain.com.tw => /var/www/project1/public
mydomain.com.tw/test => /var/www/project2
但 mydomain.com.tw/project2/detail 始终指向 mydomain.com.tw 项目路径。
project1 => laravel
project2 => vue 和使用 vue-route
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;
}
【问题讨论】:
-
您可以使用子域代替吗? (mydomain.dev 和 project2.mydomain.dev)。
-
@Lucas 否,因为需要使用相同的本地存储项。
-
您是否尝试过使用其他浏览器清除浏览器 DNS 缓存?有时这会发生在我身上。
-
@Lucas 谢谢你的建议,我通过this解决了
标签: laravel nginx routes vue.js