How to remove multiple trailing slashes?

Here are my rewrite rules:

###########
# Rewrite #
###########
# Settings
RewriteEngine On
RewriteBase /
# Cache Busting
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} "^(.+)\.\d+\.(css|js)$" [NC]
RewriteRule "^.*$" "/%1.%2" [L]
# No Index
RewriteCond %{THE_REQUEST} "\ /.*index\.php.*\ " [NC]
RewriteRule "^(.*)index\..+$" "/$1" [L,NC,R=301]
# No Question Mark
RewriteCond %{THE_REQUEST} "\ /[^?]*\?\ "
RewriteRule "^(.*)$" "/$1?" [L,R=301]
# WWW
# RewriteCond %{HTTP_HOST} !"^(?:static|www)\.(.+)$" [NC]
# RewriteCond %{HTTPS}s "^on(s)|"
# RewriteRule "^(.*)$" http%2://www.%1/$1 [L,R=301]

Everything works fine (any suggestion to improve performance or for a better regular expression is welcome, one way or another), but I am experiencing a strange situation, and I cannot figure out if this is caused by my rewrite rules or the default Apache behavior. If my URL ends with a "/", I can add as many slashes as I want without rewriting it.

For example, if in my address bar I insert the following:

Http: // [MY-HOST-NAME] ////////////////////////////

All these traits are not removed. And I still see my index.php page. If I insert the following address:

Http: // [MY-HOST-NAME] / Members ///

All of these multiple slashes are not deleted, and I can see my index.php members page. Etc...

- ? !

+1
3
RewriteCond %{THE_REQUEST} //
RewriteRule .* $0 [R]
+3

Gerbens .htaccess, . .

# if match set environment variable and start over
RewriteRule ^(.*?)//+(.*)$ $1/$2 [E=REDIR:1,N]

# if done at least one. redirect with 301
RewriteCond %{ENV:REDIR} 1
RewriteRule ^/(.*) /$1 [R=301,L]
0
RewriteEngine on
RewriteBase /

#existing rule
#remove the www.
RewriteCond %{HTTP_HOST} ^www.website.co.uk$ [NC]
RewriteRule ^(.*)$ http://local.website.co.uk/$1 [R=301,L]

#new Rule
#if its not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#and it has a trailing slash then redirect to URL without slash
RewriteRule ^(.+)/$ /$1 [L,R=301]

# rest of your existing rules go here
0
source

All Articles