【发布时间】:2016-05-10 21:41:19
【问题描述】:
我使用的htaccess如下
RewriteBase /
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} -U
RewriteRule ^.*$ - [NC]
RewriteCond %{REQUEST_URI} !-U
RewriteRule ^(.*)$ #/$1 [L]
在我的本地主机上,当我只是输入 localhost/ 时,它会重定向到 localhost/home 并且我的 Angular 应用程序运行良好。但是当我直接输入 url localhost/home 时,它会抛出 404。 我需要将其重写为 localhost/#/home
在我的 Angular 应用程序中,在 index.html 标头中,我添加了 $locationProvider.html5mode(true),html5 模式正在工作,但唯一的问题是刷新浏览器时...
提前谢谢大家。
【问题讨论】:
标签: angularjs apache .htaccess mod-rewrite