Reputation: 6302
I use this rule to remove trailing slash in URL:
RewriteRule ^(.*)/$ /$1 [L,R=301]
But this also redirects URLs with query string.
So it redirects :
http://www.example.com/something/?q=text
to
http://www.example.com/something?q=text
I need to keep URL unchanged if query string is present
Upvotes: 0
Views: 813
Reputation: 785521
You can use this rule:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.+?)/$ /$1 [L,R=301]
Upvotes: 3