美文网首页
uniapph5部署到服务器刷新页⾯出现404

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

作者: 小伙有点菜 | 来源:发表于2022-05-27 14:06 被阅读0次

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;

}

相关文章

网友评论

      本文标题:uniapph5部署到服务器刷新页⾯出现404

      本文链接:https://www.haomeiwen.com/subject/pcwmprtx.html