htaccess规则重写%3F? 和%3D到=

我需要重写我的网站,其中包含%3F的url? 和%3D到=

我试过这个规则:

RewriteCond %{HTTP_HOST} myhostname RewriteRule ^(.*)%3F(.+)%3D(.+)$ $1?$2=$3 [L,R=301] 

和这个:

 RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([^\%]+)\%3[Ff]\%3[dD]([^\ ]+)\ HTTP/ RewriteRule \.*$ %1?%2=$3 [R=301,L] 

但没有工作。

请帮助。 谢谢。

刚刚find解决scheme。 添加以下规则:

 # If THE_REQUEST contains a URL-path with a percent-encoded "?" and/or a query string with one # or more specific percent-encoded characters, and we're not already in the process of fixing # it, then copy the client-requested URL-path-plus-query-string into the "MyURI" variable. RewriteCond %{ENV:MyURI}>%{THE_REQUEST} ^>[AZ]+\ /([^\ ]+)\ HTTP/ RewriteCond %1 ^([^?]*\?([^%]*(\%(25)*([^3].|.[^D]))*)*\%(25)*3D.*)$ [NC,OR] RewriteCond %1 ^([^?]*\?([^%]*(\%(25)*([^2].|.[^6]))*)*\%(25)*26.*)$ [OR] RewriteCond %1 ^(([^%]*(\%(25)*([^3].|.[^F]))*)*\%(25)*3F.*)$ [NC] RewriteRule ^. - [NE,E=MyURI:%1] # # If any encoded question mark is present in the client-requested URI, and # no unencoded question mark is present, replace the first encoded question # mark, queue up a redirect, and then re-start mod_rewrite processing RewriteCond %{ENV:MyURI} ^[^?]+$ RewriteCond %{ENV:MyURI} ^(([^%]*(\%(25)*([^3].|.[^F]))*)*)\%(25)*3F(.*)$ [NC] RewriteRule ^. - [NE,E=MyURI:%1?%7,E=QRedir:Yes,N] # # If any encoded "=" sign follows the "?", replace it, queue # up a redirect, and re-start mod_rewrite processing RewriteCond %{ENV:MyURI} ^([^?]*\?([^%]*(\%(25)*([^3].|.[^D]))*)*)\%(25)*3D(.*)$ [NC] RewriteRule ^. - [NE,E=MyURI:%1=%7,E=QRedir:Yes,N] # # If any encoded ampersand follows the "?", replace it, queue # up a redirect, and then re-start mod_rewrite processing RewriteCond %{ENV:MyURI} ^([^?]*\?([^%]*(\%(25)*([^2].|.[^6]))*)*)\%(25)*26(.*)$ RewriteRule ^. - [NE,E=MyURI:%1&%7,E=QRedir:Yes,N] # # If we get here, there are no more percent-encoded characters which can # and should be replaced by the rules above, so do the external redirect RewriteCond %{ENV:QRedir} =Yes [NC] RewriteRule ^. http://www.example.com/%{ENV:MyURI} [NE,R=301,L] 

在这里find它: http : //forums.iis.net/t/1193309.aspx?Need+help+transforming+3F+into+and+3D+into+

你几乎肯定会得到一个403错误。 错误是由于? 是Windows和Linux上禁止的文件/目录名称字符。 这意味着当Apache尝试查找名为“/document/root/index.php?blah”(解码后)的文件或目录时,它会导致403错误。 这是.htaccess文件被读取之前,所以你不能在.htaccess文件中使用mod_rewrite覆盖这个403错误或在.htaccess文件中定义的ErrorDocument来捕获此错误。

捕获%3f的唯一方法是在“VirtualHost”中使用mod_rewrite或ErrorDocument,例如在httpd-vhosts.conf中(或者在主服务器configuration中,如果没有任何“虚拟主机”,例如在httpd.conf中)。