A
A
Anton2015-12-30 18:04:09
Apache HTTP Server
Anton, 2015-12-30 18:04:09

How to prevent a bunch of slashes at the end of the address bar?

Friends, how to use .htaccess to redirect a user from such an address site.com/////////// to such site.com/ (or without a slash at the end). Should be relevant for site.com/folder///////////
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HAbRAhabp, 2015-12-30
@HAbRAhabp

.htaccess, mod_rewrite and duplicate slashes

X
xmoonlight, 2015-12-30
@xmoonlight

Bullshit business:

####remove many slashes####
RewriteCond %{THE_REQUEST} \ (.*)//+(.*)\	[NC]
RewriteRule (.*) %1/%2 [R=301,L]

####remove trailing ;,.()[] ####
RewriteCond %{REQUEST_URI} ^(.*[;,.\(\)\[\]]+)$
RewriteRule ^(.*[^;,.\(\)\[\]]+) /$1 [R=301,L]

####add trailing slash####
RewriteCond %{REQUEST_URI} !^(.*\/[^\/]+\.[^\/]+)$
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question