Kevin Smith
Kevin Smith

Reputation: 111

This rewriting code is changing special characters which is unexpected

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%2525258‌​1

Upvotes: 1

Views: 18

Answers (1)

Panama Jack
Panama Jack

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

Related Questions