mod_rewrite的保持锚链接 [英] mod_rewrite keeps anchor link
问题描述
我想 example.com/site/about#whoami
被重定向到 example.com/site/?page=about#whoami
使用mod_rewrite的指令,但我对如何做不知道
I want example.com/site/about#whoami
to be redirected to example.com/site/?page=about#whoami
using mod_rewrite directives, but I have no idea on how to do that
推荐答案
请注意:锚字符#
可以传递,但对替代的网址,除非没有影响重定向到锚存在的页面。虽然阿帕奇做不到窗口的滚动下到锚,浏览器会做,在这种情况下。下面是有关重定向锚的一些 Apache的信息
NOTE: Anchor character #
may be passed, but it has no effect on the substitution URL unless the redirection is to a page where the anchor exists. Although Apache cannot do the scrolling of the window down to the anchor, the browser will do it in that case. Here is some 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
字符串网站
是固定的。
字符串什么
可能包含一个锚#
键,它会替换URL进行传递。
String anything
may contain an anchor #
and it will be passed in the substitution URL.
这篇关于mod_rewrite的保持锚链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!