Мне нужно переписать URL-адрес моего сайта, который содержит% 3F на? и% 3D в =
Я пробовал это правило:
RewriteCond %{HTTP_HOST} myhostname
RewriteRule ^(.*)%3F(.+)%3D(.+)$ $1?$2=$3 [L,R=301]
И это:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\%]+)\%3[Ff]\%3[dD]([^\ ]+)\ HTTP/
RewriteRule \.*$ %1?%2=$3 [R=301,L]
Но ничего не получилось.
Помогите, пожалуйста. Спасибо.
Только что нашел решение. Это сделало добавление следующих правил:
# 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} ^>[A-Z]+\ /([^\ ]+)\ 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]
Нашел здесь: 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, поэтому вы не можете использовать mod_rewrite в файле .htaccess для переопределения этой ошибки 403 или ErrorDocument, определенный в файле .htaccess, чтобы отловить эту ошибку.
Единственный способ поймать% 3f - использовать mod_rewrite или ErrorDocument в "VirtualHost" например в httpd-vhosts.conf (или в конфигурации основного сервера, если нет никаких виртуальных хостов, например, в httpd.conf).