How do you remove multiple slashes in URI HTACCESS

parksdesign
01-02-2017 18:51

http://domain.com/test/test/ > http://domain.com/test/test

# Strip trailing slash(es) from uri
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)[/]+$ $1 [NC,R,L]

http://domain.com//test//test// > http://domain.com/test/test/

# Merge multiple slashes in uri
RewriteCond %{THE_REQUEST} ^[A-Z]+\ //*(.+)//+(.*)\ HTTP
RewriteRule ^ /%1/%2 [R,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ //+(.*)\ HTTP
RewriteRule ^ /%1 [R,L]

Change R to R=301 if everything works fine after testing...

Average rating: 0 (0 Votes)

You cannot comment on this entry