如何使用htaccess的重写URL以HTML定位标记(#) [英] How to use htaccess to rewrite url to html anchor tag (#)

查看:266
本文介绍了如何使用htaccess的重写URL以HTML定位标记(#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个情况我要采取以下网址:

I have a situation where I want to take the following URL:

/ 1 /约翰

和有它重定向使用Apache的htaccess文件去

and have it redirect using Apache's htaccess file to go to

/page.php?id=1&name=john#john

/page.php?id=1&name=john#john

,使其进入一个html锚与约翰的名字。

so that it goes to an html anchor with the name of john.

我发现了很多参考转义特殊字符,并添加[NE]标志,以便重定向忽略#标志,但这些不工作。例如,添加[NE,R]表示的URL正好出现在浏览器的地址与原始:<一href="http://mysite.com/page.php?id=1&name=john#john">http://mysite.com/page.php?id=1&name=john#john.

I've found a lot of reference to escaping special characters, and to adding the [NE] flag so that the redirect ignores the # sign, but these don't work. For example, adding [NE,R] means that the URL just appears in the browser address as the original: http://mysite.com/page.php?id=1&name=john#john.

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

这是可以使用的 [NE]标志(noescape)。

This is possible using [NE] flag (noescape).

在默认情况下,特殊字符,如&放大器;和β,例如,将被转化成它们的十六进制code当量。使用[NE]标志prevents这种情况的发生。

By default, special characters, such as & and ?, for example, will be converted to their hexcode equivalent. Using the [NE] flag prevents that from happening.

更多信息<一个href="http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne">http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne

这篇关于如何使用htaccess的重写URL以HTML定位标记(#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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