【发布时间】:2018-06-15 22:59:30
【问题描述】:
我在 index.html 中编写了一个解析 URL 并重定向到正确目的地的 js 脚本。例如,它解析 example.com/#/info 并显示正确的链接。
我希望它处理任何 URL,例如 example.com/xyz。但它显示 404 错误。
当我像这样添加.htaccess 时:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/#
# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /#/$1 [L,R=301]
但它不起作用。它会引发 too_many_redirects 错误。
【问题讨论】:
-
哈希不发送到网络服务器——Apache,包括 PHP。
标签: javascript apache .htaccess mod-rewrite url-rewriting