【发布时间】:2013-02-08 15:16:09
【问题描述】:
我希望使用 mod_rewrite 指令将 example.com/site/about#whoami 重定向到 example.com/site/?page=about#whoami,但我不知道该怎么做
【问题讨论】:
标签: apache mod-rewrite anchor
我希望使用 mod_rewrite 指令将 example.com/site/about#whoami 重定向到 example.com/site/?page=about#whoami,但我不知道该怎么做
【问题讨论】:
标签: apache mod-rewrite anchor
注意:可以传递锚字符 #,但它对替换 URL 没有影响,除非重定向到存在锚的页面。尽管 Apache 不能将窗口向下滚动到锚点,但在这种情况下浏览器会这样做。这是一些Apache information about redirecting anchors
你可以试试这样的:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/(.*)/? site?page=$1 [NC,NE,L]
地图
http://example.com/site/anything
到
http://example.com/site/?page=anything
字符串site 被认为是固定的。
字符串 anything 可能包含一个锚点 #,它将在替换 URL 中传递。
【讨论】: