Reputation: 111
This code is for purpose of removing empty parameters from URL by .htaccess:
RewriteCond %{QUERY_STRING} ^(.+?&)?[^=]+=(?:&(.*))?$
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=302,L]
It removes empty URLS but the problem is it's changing special characters in URL which caused many errors. e.g:
山西省
changes to: %252525E5%252525B1%252525B1%252525E8%252525A5%252525BF%252525E7%2525259C%25252581
Upvotes: 1
Views: 18
Reputation: 24478
Try using the NE
flag in your rule.
RewriteCond %{QUERY_STRING} ^(.+?&)?[^=]+=(?:&(.*))?$
RewriteRule ^ %{REQUEST_URI}?%1%2 [R=302,NE,L]
http://httpd.apache.org/docs/current/rewrite/flags.html#flag_ne
Upvotes: 1