How to convert plus (+) sign to “=+” with htaccess?

北战南征 提交于 2019-12-13 15:51:49

问题


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]

回答1:


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



来源:https://stackoverflow.com/questions/8446545/how-to-convert-plus-sign-to-with-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!