htaccess QUERY_STRING urldecode [英] htaccess QUERY_STRING urldecode

查看:38
本文介绍了htaccess QUERY_STRING urldecode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem concerning .htaccess and QUERY_STRING.

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

I try redirecting an URL with my htaccess that looks like this:

http://mydomain.tld/out/http%3A%2F%2Fotherdomain.tld%3Fparam%3D0

http://otherdomain.tld?param=0

我使用带有 REQUEST_URI 的 RewriteCond 和 RewriteRule 来重定向 url,一切正常,因为 REQUEST_URI 在 htaccess 中默认为 urldecoded.

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.

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

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

所以 htaccess 获取链接并尝试重定向它,但由于问号,htaccess认为"问号后面的所有内容都是 QUERY_STRING.

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.

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

The problem: apache2 doesn't urldecode the QUERY_STRING. So what happens is that htaccess redirects to

http://otherdomain.tld?param%3D0

哪个会失败.

所以我的问题是:

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

提前致谢!

干杯

推荐答案

你不需要将 [QSA] 添加到你的重写规则中来强制 htaccess 也编码查询字符串.

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

这篇关于htaccess QUERY_STRING urldecode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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