我将我的角度.js项目转换为html5mode,直到我尝试刷新页面为止,一切正常。我做了一些研究,发现它与服务器端有关。
我在索引中添加<base href="/index.html">
.html在所有内容之前
。然后将$locationProvider.html5Mode(true).hashPrefix('!');
添加到我的应用配置中。
正如其他问题中所建议的,我将这些行添加到我的 .htaccess 中
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
但我的问题还在继续。
我该怎么办?
我的问题已经解决了
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) /#!/$1 [NE,L,R=301]
</IfModule>