mod_rewrite的URL编码已经urlen codeD查询参数 - 任何方式禁用此? [英] mod_rewrite urlencoding an already urlencoded querystring parameter - any way to disable this?

查看:113
本文介绍了mod_rewrite的URL编码已经urlen codeD查询参数 - 任何方式禁用此?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些非常基本的mod_rewrite的规则:

we have some very basic mod_rewrite rules:

RewriteRule ^something.swf$ http://www.newdomain.com/something.swf [R=302,L]

mod_rewrite的接缝来完成其工作,并且如果用户正在访问:

mod_rewrite seams to do its job, and if the user is accessing:

something.swf?参数=值,它被正确重定向到<一个href=\"http://www.newdomain.com/something.swf?param=value\">http://www.newdomain.com/something.swf?param=value

something.swf?param=value, it is redirected correctly to http://www.newdomain.com/something.swf?param=value

问题是在这种情况:

www.olddomain.com/something.swf?param=URL_EN$c$cD_VALUE

www.olddomain.com/something.swf?param=URL_ENCODED_VALUE

什么最终发生的是mod_rewrite的采取它在它的自我重新urlen code中的查询字符串参数

what ends up happening is mod_rewrite takes it upon it self to re-urlencode the querystring param

所以用户是最终得到的是:

so what the user is end up with is:

www.olddomain.com/something.swf?param=URL_ENCODED_VALUE

重定向到

www.newdomain.com/something.swf?param=URL_ENCODED_VALUE_OF_URL_ENCODED_VALUE

所以我们最终采用了双层urlen codeD值。 boourns!

so we end up with a double-urlencoded value. boourns!

虽然我明白,我们可以做一个\\?(。*)...?$条规则对于这一点,我在想,必须有办法告诉了mod_rewrite不要将urlen code中的查询字符串PARAMS .. 。我们想避免使用2规则,因为有效路径是:

while i do understand we could make a \?(.*) ... ?$1 rule for this, i am thinking there must be a way to tell mod_rewrite NOT to urlencode the query string params... we would like to avoid using 2 rules since valid paths are:

something.swf (no query string)

something.swf?someparams...

所以啊,idealy ......只是告诉mod_rewrit:请,没有查询字符串参数...只是直接中继的URL编码,以通过R新的URL,302

so yea, idealy... just tell mod_rewrit: please, no urlencoding of querystring params... just direct passthru to the new url via r,302.

人?

谢谢!

推荐答案

做到这一点的方法是通过NE(无路可逃)paramater。

the way to accomplish this is via the NE (no escape) paramater.

RewriteRule ^something.swf$ http://www.newdomain.com/something.swf [R=302,L]

其实应该读

RewriteRule ^something.swf$ http://www.newdomain.com/something.swf [R=302,NE,L]

这将迫使mod_rewrite的给所有的查询字符串值,因为他们,没有做任何编码/逃脱。

this will force mod_rewrite to leave all query string values as they are, without doing any encoding / escaping.

一样容易认为:)

这篇关于mod_rewrite的URL编码已经urlen codeD查询参数 - 任何方式禁用此?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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