如何通过重写规则绕过%23(井号),而不会丢失数据? [英] How to bypass %23 (hash sign) through RewriteRule without data loss?
问题描述
我有如下的的.htaccess
文件:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/command
RewriteRule .* /command/rewritehandler.php?q=%{REQUEST_URI} [B]
请参阅规格在目前悬而未决的问题<一href="http://stackoverflow.com/questions/29376788/mod-rewrite-directives-and-valid-invalid-utf-8-characters-after-first-character">mod_rewrite指令和有效/无效UTF-8字符REQUEST_URI 的第一个字符之后。
如果请求服务器以下 / AAA%,23%23AA
然后 rewritehandler.php
只接收 / AAA
。貌似 REQUEST_URI
在只处理数据%23
。我该怎么输入呢?
See specs at currently unanswered question mod_rewrite directives and valid/invalid utf-8 characters after first character of REQUEST_URI .
If request to server the following /aaa%23%23aa
then rewritehandler.php
receives only /aaa
. Looks like REQUEST_URI
only handles data before %23
. What I should type instead?
推荐答案
从捕捉值的RewriteCond
,然后使用反向引用,使其工作:
Capture value from RewriteCond
and then use a back-reference to make it work:
RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)
RewriteRule !^command/ /command/rewritehandler.php?q=%1 [NC,B,L,QSA]
这篇关于如何通过重写规则绕过%23(井号),而不会丢失数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!