0

I am using following directives in my htaccess to remove trailing slashs from my uris to prevent duplicate content. However these directives also remove any query string, that might be present.

RewriteCond %{HTTP_HOST} ^(www.)?mydomain\com$ [NC]
RewriteRule ^(.+)/$ http://www.mydomain.com/$1 [R=301,L]

I'd like to know how to remove a potential trailing slash from my URI, but also preserve query strings.

Linus Kleen
  • 33,871
  • 11
  • 91
  • 99
  • possible duplicate of [How can I mod\_rewrite and keep query strings?](http://stackoverflow.com/questions/12873137/how-can-i-mod-rewrite-and-keep-query-strings) – Michael Berkowski Oct 13 '12 at 12:39

1 Answers1

1

There's a RewriteRule option flag for that: QSA.

Appends any query string from the original request URL to any query string created in the rewrite target

Linus Kleen
  • 33,871
  • 11
  • 91
  • 99