学无先后,达者为师

网站首页 编程语言 正文

h5 uniapp history模式下刷新页面404

作者:沉、睡 更新时间: 2022-01-30 编程语言

h5 uniapp history模式下刷新页面404

问题:uniapp 的history 把#去掉了,但是当刷新页面的时候出现404 解决方案 需要服务端支持

如果 URL 匹配不到任何静态资源,则应该返回同一个 index.html 页面

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>

nginx

location / {
  try_files $uri $uri/ /index.html;
}

原文链接:https://blog.csdn.net/zz975896590/article/details/119991104

栏目分类
最近更新