I would like to remove duplicate URLs by removing the trailing slash from URLs. If someone enters a URL like http://example.com/something/
it should 301 redirect to http://example.com/something
.
Obviously the query string must be preserved when present.
Here is my .htaccess
file at the moment (for localhost):
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~macuser/example.com/
# RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /~macuser/example.com/index.php?/$1 [L]
</IfModule>
Also, please feel free to comment if the above can be improved in any way.