当前位置:   article > 正文

解决VUE打包后放到服务器出现空白页、页面路径、刷新页面出现404的问题

vue打包后在服务器上其他页面刷新显示not found

文章就列举 apache和iis服务器的配置方式,其他自己研究

在wampserver apache 的环境下的话: 通用配置: 在wampserver--apache--httpd.conf LoadModule rewrite_module modules/mod_rewrite.so 去掉前面的# AllowOverride none --- none改为all 只需要改前2个地方 好像第二个地方已经默认改好了的 AllowOverride None 这个不用改

项目打包配置: vue文件夹里 1.config/index.js build.assetsPublicPath : '/' 这种其实就是绝对定位了 2.router/index.js base: '/' 这个是默认值了 打包后的文件放在服务器根目录 然后添加.htaccess文件 配置如下 RewriteEngine On RewriteBase / RewriteRule ^index.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L]

重启服务 打开http://localhost:8033/ 这样就直接访问

1.config/index.js build.assetsPublicPath : './' 2.router/index.js base: '/dist/' 文件放在dist/ http://localhost:8033/dist/ 就这样访问 RewriteEngine On RewriteBase / RewriteRule ^index.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /dist/index.html [L]

在iis 的环境下的话: 1.config/index.js build.assetsPublicPath : '/' 这种其实就是绝对定位了 2.router/index.js base: '/' 这个是默认值了 文件放在根目录,http://localhost:8033/ 这样就直接访问

1.config/index.js build.assetsPublicPath : './' 2.router/index.js base: '/dist/' 文件放在dist/ http://localhost:8033/dist/ 就这样访问 上面的代码加dist

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/619349
推荐阅读
相关标签
  

闽ICP备14008679号