How to bypass %23 (hash sign) through RewriteRule without data loss?

你。 提交于 2019-12-24 15:43:01

问题


I have the following .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/command
RewriteRule .* /command/rewritehandler.php?q=%{REQUEST_URI} [B]

See specs at currently unanswered question https://stackoverflow.com/questions/29376788/mod-rewrite-directives-and-valid-invalid-utf-8-characters-after-first-character . 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?


回答1:


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]


来源:https://stackoverflow.com/questions/29395719/how-to-bypass-23-hash-sign-through-rewriterule-without-data-loss

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