htaccess QUERY_STRING urldecode

sla*_*dda 6 .htaccess apache2 query-string

我有一个关于.htaccess和QUERY_STRING的问题.

我尝试使用我的htaccess重定向URL,如下所示:

http://mydomain.tld/out/http%3A%2F%2Fotherdomain.tld%3Fparam%3D0
Run Code Online (Sandbox Code Playgroud)

http://otherdomain.tld?param=0
Run Code Online (Sandbox Code Playgroud)

我使用RewriteCond和RewriteRule与REQUEST_URI重定向url,一切正常,因为在htaccess默认情况下REQUEST_URI是urldecoded.

但是,当我通过电子邮件将链接发送到Hotmail时,Hotmail会对斜杠和问号进行编码.结果如下:

http://mydomain.tld/out/http%3A//Fotherdomain.tld?param%3D0
Run Code Online (Sandbox Code Playgroud)

所以htaccess接受链接并尝试重定向它,但由于问号,htaccess"认为"问号背后的一切都是QUERY_STRING.

问题:apache2没有对QUERY_STRING进行urldecode.那么会发生什么是htaccess重定向到

http://otherdomain.tld?param%3D0
Run Code Online (Sandbox Code Playgroud)

哪个会失败.

所以我的问题是:

如何告诉htaccess urldecode QUERY_STRING或使用完整请求的url(urlendcoded或urldecoded),包括问号后面的部分

提前致谢!

干杯

小智 0

您无需添加[QSA]重写规则来强制 htaccess 对查询字符串进行编码。

http://httpd.apache.org/docs/current/en/mod/mod_rewrite.html