I\'ve successfully modified my .htaccess file to remove trailing slashes on most pages but I\'m wondering how to exempt my home page/directory? For example:
domain.
Redirects request for all URLs ending in a /
except for the root:
RedirectMatch 301 ^(.+)/$ $1
OK. After a bunch of trial and error I answered my own question.
The third line denotes that there has to be something in the URI in order to perform the redirect thus not redirecting if the url just contains the initial slash.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ http://www.domain.com/$1 [R=301,L]
How about
RewriteEngine On
RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1