vue打包部署解决页面刷新404的问题
1.Nginx服务器配置:
location ^~/vue {
alias /data/wwwroot/vue;
index index.html;
try_files $uri $uri/ /vue/index.html;
}
2.Apache服务器配置:
开启mod_rewrite模块,设置allowAllOveride All并在项目目录下创建.htaccess文件,内容如下:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /vue/index.html [L]