htaccess QUERY_STRING网址解码 [英] htaccess QUERY_STRING urldecode

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

问题描述

我遇到了有关.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

我将RewriteCond和RewriteRule与REQUEST_URI一起使用来重定向url,并且自REQUEST_URI以来一切正常

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会使用url解码斜杠和问号。结果看起来像这样:

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进行url解码。那么发生的是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进行url解码或使用完整的请求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/当前/zh/mod/mod_rewrite.html

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

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