问题描述
我想每个URL包含转换+为= +
例如该URL:
http://www.bedavaemlaksitesi.com/mersinemlakrehberi210/index3.php?+
应该是这样的:
http://www.bedavaemlaksitesi.com/mersinemlakrehberi210/index3.php?=+
尝试,和其他一些线路,但不能正常工作,到目前为止,我猜它会导致一个循环什么的。
重写规则^([^ / \。] +)+([^ / \。] +)?$ $ 1 = + $ 2 [R]
我只是要去给你的具体例子的字面上的答案。不知道是否会真正帮助你:
的RewriteCond%{QUERY_STRING} ^([+])$
重写规则/index3.php$ index3.php?=(1%)[R,L]
您不能repleace每个 +
的QS,因为你需要一个单独的条件,首先与之相匹配的。
另外你原来的规则:
重写规则^([^ / \。] +)+([^ / \。] +)?$ $ 1 = + $ 2 [R]
逃离了charclass将点是多余的, [^ /]
就足够了。你至少需要两组 /
之间的分隔符是有道理的。但是你不能在QUERY_STRING匹配存在,这是独立于当前的文件路径来处理。
请参阅阿尔索斯:ServerFault:所有你想知道的关于mod_rewrite规则,但不敢问 - 和 - HttpdWiki:操纵查询字符串
I want to convert every url which contains "+" to "=+"
for example that url:
http://www.bedavaemlaksitesi.com/mersinemlakrehberi210/index3.php?+
should be like this:
http://www.bedavaemlaksitesi.com/mersinemlakrehberi210/index3.php?=+
tried that and few other lines but doesn't work so far, i'm guessing it causes a loop or something.
RewriteRule ^([^/\.]+)+([^/\.]+)?$ $1=+$2 [R]
I'm just gonna give you a literal answer for that specific example. Not sure if that will actually help you:
RewriteCond %{QUERY_STRING} ^([+])$
RewriteRule /index3.php$ index3.php?=(%1) [R,L]
You cannot repleace each +
in the QS, as you do need a separate condition to match it first.
Also about your original rule:
RewriteRule ^([^/\.]+)+([^/\.]+)?$ $1=+$2 [R]
Escaping the dot in the charclass is redundant, [^/.]
suffices. And you need at least a separator between the two groups /
to make sense. But you can't match the query_string there, that's handled separately from the current filepath.
See alsos: ServerFault: Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask? -and- HttpdWiki: Manipulating the Query String
这篇关于如何转换加号(+)号到" = +"与htaccess的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!