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.com/test/ successfully redirects to domain.com/test
HOWEVER, when I hit my domain it will append the root document
domain.com/ redirects to domain.com/index.php
Is there a condition that I can add to ignore root url trailing slash so that it doesn’t attempt to remove the trailing slash and add my default script? Here’s what I have so far:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]
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.