uniapph5部署到服务器刷新页⾯出现404

uniapph5部署到服务器刷新页⾯出现404

解决⽅案⼀:

将uniapp的manifest.json中h5配置的路由模式设为hash模式

优点:当前端没办法接触到服务器的时候,简单修改下配置就能修复

缺点:换成hash后url中带#号,不美观,⽽且会影响传参

不能接受这个缺点可以参考解决⽅案⼆。

解决⽅案⼆:

路由模式设置为history的同时简单配置下服务器即可

①.Apache

<IfModule mod_rewrite.c>

  RewriteEngine On

  RewriteBase /

  RewriteRule ^index\.html$ - [L]

  RewriteCond %{REQUEST_FILENAME} !-f

  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule . /index.html [L]

</IfModule>

除了 mod_rewrite,你也可以使⽤ 。

②.nginx

location / {

  try_files $uri $uri/ /index.html;

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容