0
我想example.com/site/about#whoami
使用mod_rewrite的指令被重定向到example.com/site/?page=about#whoami
,但我对如何做到这一点mod_rewrite的保持锚链接
我想example.com/site/about#whoami
使用mod_rewrite的指令被重定向到example.com/site/?page=about#whoami
,但我对如何做到这一点mod_rewrite的保持锚链接
注意不知道:锚文字#
可以传递,但对替代无影响除非重定向是存在锚点的页面。尽管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
字符串假定3210是固定的。
字符串anything
可以含有锚#
,它会在替代URL被传递。
哦,谢谢,我明白了。我已经测试过,它仍然将页面向下滚动到锚点:D – ranisalt 2013-02-22 22:15:38