mod_rewrite keeps anchor link

我的未来我决定 提交于 2019-12-01 14:10:32

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

You may try something like this:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/(.*)/?   site?page=$1  [NC,NE,L]

Maps

http://example.com/site/anything

To

http://example.com/site/?page=anything

String site is assumed to be fixed.

String anything may contain an anchor # and it will be passed in the substitution URL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!