问题
I have a problem concerning .htaccess and QUERY_STRING.
I try redirecting an URL with my htaccess that looks like this:
http://mydomain.tld/out/http%3A%2F%2Fotherdomain.tld%3Fparam%3D0
to
http://otherdomain.tld?param=0
I use RewriteCond and RewriteRule with the REQUEST_URI to redirect the url and everything works fine since REQUEST_URI is urldecoded by default in the htaccess.
However, when I email the link to Hotmail, Hotmail urldecodes the slashes and the question mark. The result looks like this:
http://mydomain.tld/out/http%3A//Fotherdomain.tld?param%3D0
So htaccess takes the link and tries to redirect it but due to the question mark the htaccess "thinks" everything behind the question mark is a QUERY_STRING.
The problem: apache2 doesn't urldecode the QUERY_STRING. So what happens is that htaccess redirects to
http://otherdomain.tld?param%3D0
which will fail.
So my question is:
How can I tell htaccess to either urldecode the QUERY_STRING or use the full requested url (either urlendcoded or urldecoded) including the part after the question mark
Thanks in advance!
Cheers
回答1:
You need not add [QSA]
to your rewrite rule to force htaccess to encode query string too.
http://httpd.apache.org/docs/current/en/mod/mod_rewrite.html
来源:https://stackoverflow.com/questions/7246497/htaccess-query-string-urldecode