1

Basically, I have a rewrite rule, that removes the trailing slash from a URL. I'm currently using IIRF (IIS 6), and the rule will take the following URL and remove the slash like so:

http://test.site.com/home-search/communities/state/city/

and successfully changes it to:

http://test.site.com/home-search/communities/state/city

but when a query string is there, it automatically, adds the trailing slash back in. So, basically adding ?param1=xx&param2=yy to the URL, re-adds the slash before the query string.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} $ !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/$

RewriteRule ^(.*)/$ $1 [R=301,QSA]

If I add the following rule, I get a redirect loop that breaks the page, but does remove the trailing slash properly.

RewriteRule ^(.*)\/(\?.*)?$ $1 [R=302,QSA]

Any idea what I could possibly be doing wrong?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.