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

文章就列举 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值