mod_rewrite的保持锚链接 [英] mod_rewrite keeps anchor link

查看:145
本文介绍了mod_rewrite的保持锚链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆