实现效果
- laravel 项目通过
http://yoursite.com/
访问
- vue 项目通过
http://yoursite.com/client
访问
修改 vue.config.js
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/client/' : '/'
}
配置 nginx
server {
root /www/laravel-project-path/public;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.html index.htm index.php;
}
# 匹配到 client 开头的地址
location ^~ /client/ {
alias /www/vue-project-path/; # vue 项目的路径
index index.html;
try_files $uri $uri/ /client/index.html; # 这里的 client 需要和 vue.config.js 中一致
}
}