需要转义#(哈希/磅)字符在.htaccess重写规则 [英] need to escape # (hash/pound) character in .htaccess rewrite rule

查看:642
本文介绍了需要转义#(哈希/磅)字符在.htaccess重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在的问题是相当简单的,但我没能找到几个小时的答案了。

The question is fairly simple but I was not able to find an answer for hours now.

我需要做的是:

RewriteRule ([^#])#(.*) $1\%23$2

这基本上意味着我要URL转义的再用井号里面说到我从外部codepiece。

Which basically means I want to url escape the freaking hash sign which comes to me from an external codepiece.

反斜线( \ )不起作用摆脱这种迹象......请不要建议使用 23%而不是,因为它不正常工作。

backslash (\) does not work to escape this sign... and please don't suggest using %23 instead # because it does not work as well.

%2 3不匹配,因为它根本就没有 = =%23

(%23 does not match a # because it simply is not == %23)

推荐答案

一个URL的哈希部分不适用于重写。当Web浏览器发送一个URL请求到web服务器将其发送之前的所有内容的散列标志。哈希是唯一可用的客户端(如JavaScript的code可以看到它)。

The hash part of a URL is not available for rewriting. When a web browser sends a URL request to a web server it sends everything up to the hash sign. The hash is only available on the client (e.g. JavaScript code can see it).

这篇关于需要转义#(哈希/磅)字符在.htaccess重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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