Uniapp 上传h5不在根目录下刷新页面访问404解决方案
·
问题:h5上传服务器运行后,刷新404,路由失效
这是路由特性决定的,还是在这个文档里说的很清楚
https://router.vuejs.org/zh/guide/essentials/history-mode.html#%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90
想用history又想刷新直接跳到对应页面,就需要后台服务器配置
- 1.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>
- 2.Nginx
location / {
try_files $uri $uri/ /index.html;
}
引用地址
https://blog.csdn.net/V1040375575/article/details/139611811
其他方案
https://blog.csdn.net/lianzhang861/article/details/112437213
更多推荐



所有评论(0)