mod rewrite - Removing special characters from query string in .htaccess -



mod rewrite - Removing special characters from query string in .htaccess -

i've come across similar questions, such this one, , found similar instructions on mod_rewrite tutorials.

i've determined need along lines of

rewriterule ^(.*)<(.*)$ /$1$2 [l,r=301] rewriterule ^(.*)>(.*)$ /$1$2 [l,r=301]

this works http://domain.com/<>, not work http://domain.com?a=<>

i've added following, in attempts remove these characters query string:

rewritecond %{query_string} ^(.*)<(.*)$ rewriterule ^(.*)$ /$1?%1%2 [l,r=301] rewritecond %{query_string} ^(.*)>(.*)$ rewriterule ^(.*)$ /$1?%1%2 [l,r=301]

this did not alter anything. i've tried escaping < , > in regex (i.e. ^(.*)\<(.*)$).

the end result trying accomplish have

http://domain.com/<whatever> turn http://domain.com/whatever, ,

http://domain.com/a=<whatever>&b=whatever turn http://domain.com/a=whatever&b=whatever

< encoded %3c , > encoded %3e browsers. have rules this:

rewritecond %{query_string} ^(.*?)(?:%3c|%3e)(.*)$ rewriterule ^(.*)$ /$1?%1%2 [l,r=302,ne]

this redirect http://domain.com/?a=<whatever>&b=whatever http://domain.com/?a=whatever&b=whatever

.htaccess mod-rewrite

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -