shsteimer
shsteimer

Reputation: 28800

mod_rewrite re-encoding Query String Parameters

I have the following mod_rewrite rule, which strips the .html extension from requests and replaces it with a trailing /

# Handle requests to pages ending with .html
RewriteCond    %{REQUEST_URI} .*.html$
RewriteRule    (.*).html$ $1/ [R=301,QSA,L]

I have discovered that if my query param contains a space, already encoded, the redirect is being re-encoded. So if the initial request is for "/search-results.html?q=some%20string", that gets rewritten to "/search-results/?q=some%2520string"

Is there another parameter I can give to mod_rewrite to prevent this re-encoding from happening?

Upvotes: 1

Views: 1104

Answers (1)

Arun
Arun

Reputation: 46

Use the [NE] flag to avoid duplicate encoding.

Upvotes: 1

Related Questions