我用
$ locationProvider.html5Mode(true);从网址中删除#

http://seagullinteractive.com/#/about:-重新加载后的工作

http://seagullinteractive.com/about:-现在不起作用,不是问题

最佳答案

您需要在根目录中创建.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]


需要把上面的重写规则。那会没事的。当您调用http://seagullinteractive.com/about时,服务器将查找名称“ about”的目录,该目录实际上将不存在,结果将得到404。如果在服务器上找不到带有请求URI的资源,则需要重定向到index.html(或包含ng-app的页面中的任何一个)。

关于javascript - 在重载页面后的Angular js中,它说在使用$ locationProvider.html5Mode(true);之后服务器404上找不到错误;,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44841310/

10-14 09:14