Jump to content

Exclude root domain from trailing slash code


themistral

Recommended Posts

Hi guys,

 

I need some help with a redirect.

 

I currently have the following to add a trailing slash to the end of my URL.

 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(.*)/$
RewriteCond %{REQUEST_URI} !^(.*).(css|CSS|js|JS|png|PNG|jpg|JPG|jpeg|JPEG|gif|GIF|zip|ZIP|xml|XML|pdf|PDF|html|HTML|php|PHP|txt|TXT)$
RewriteRule ^(.*)$ /$1/ [QSA,R=301,L] 

 

This works fine.

 

However, when using the google UTM code appended to the homepage, the URL breaks, so I need to remove the trailing slash.

I've tried a number of things but nothing is working.

 

Can anyone advise how I exclude the homepage in the above code?

 

I was thinking

RewriteCond %{REQUEST_URI} !^$

but that's not working

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.