.htaccess - htaccess QUERY_STRING urldecode

标签 .htaccess apache2 query-string

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

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

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。

但是,当我通过电子邮件将链接发送到 Hotmail 时,Hotmail urldecodes 斜杠和问号。结果如下所示:
http://mydomain.tld/out/http%3A//Fotherdomain.tld?param%3D0

因此 htaccess 获取链接并尝试重定向它,但由于问号,htaccess “认为”问号后面的所有内容都是 QUERY_STRING。

问题:apache2 不会对 QUERY_STRING 进行 urldecode。那么发生的事情是 htaccess 重定向到
http://otherdomain.tld?param%3D0

这将失败。

所以我的问题是:

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

提前致谢!

干杯

最佳答案

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

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

关于.htaccess - htaccess QUERY_STRING urldecode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7246497/

相关文章:

apache - htaccess 重定向不适用于 HTTPS - 400 错误请求 Apache 2.4.6

.htaccess - AllowOverride None,并且 .htaccess 有效

apache2 - ProxyPass 将 304 状态修改为 200 并添加 content-type

perl - 如何在不重新启动的情况下调试 mod_perl2 模块?

.htaccess - 使用 .htaccess 重写查询字符串而不改变链接结构

html - angular2 不在服务器上加载页面,同样的事情在本地机器上工作

javascript - 想要将当前网址更改为上一页网址(第二个域)?

xml - 如何使用 Scala 创建 xhtml 查询字符串?

apache - 让 .htaccess RewriteRule 重定向到脚本 "in current dir"(而不是显式路径)

angularjs - 将复杂的 javascript 对象转换为查询字符串时遇到问题