0

For some reason some links create slashes at the end of urls. I discovered the same link in a different device can or cannot add a slash at the end of the URL.

Due to my htaccess structuring I sometimes get errors if the URLs have slashes. Is there a way to remove them from URLs with htaccess?

EG:

example.com/s/

instantly redirects to:

example.com/s
lisovaccaro
  • 32,502
  • 98
  • 258
  • 410
  • possible duplicate of [Remove trailing slash using .htaccess except for home / landing page](http://stackoverflow.com/questions/4167539/remove-trailing-slash-using-htaccess-except-for-home-landing-page) – t0mm13b Jul 01 '12 at 01:56

2 Answers2

1

A similar question gave this answer:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ http://www.domain.com/$1 [R=301,L]
Community
  • 1
  • 1
lobianco
  • 6,226
  • 2
  • 33
  • 48
0

This do the job and you don't need to specify the domain :

RewriteRule ^(.+)/$ /$1 [R=301,L]

anasaitali
  • 1,504
  • 21
  • 30