【发布时间】:2017-01-22 07:52:07
【问题描述】:
我已经创建了 AngularJS 应用程序。
使用下面的 URL 可以正常工作:
http://localhost/AngularDemo/about
如果我像下面这样修改上面的 URL,它会将我带到一个 404 页面:
http://localhost/AngularDemo%2Fabout
我对 .htaccess 文件做了一些改动
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html#! [L]
【问题讨论】:
-
为什么要在 URL 中使用转义编码?
-
通过一些像 Linked In 这样的用户代理,我们确实得到了像上面这样的编码 URL,所以如果我在应用程序中使用该 url,它会将我们带到 404 页面。以上网址是一个示例
标签: javascript angularjs .htaccess