Remove trailing slash with htaccess but preserve query string
Posted
by
soundseller
on Stack Overflow
See other posts from Stack Overflow
or by soundseller
Published on 2012-04-13T17:25:51Z
Indexed on
2012/04/13
17:30 UTC
Read the original article
Hit count: 281
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.
© Stack Overflow or respective owner