Answer the question
In order to leave comments, you need to log in
How to set up a 301 redirect from the main with // or more to the main without slashes?
You need to set up a 301 redirect, which, if you enter more than two slashes on the main page, will redirect to the main page without slashes.
That is from:
site.com///
to
site.com
Now still site.com///
Found a solution for internal pages
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
But this code doesn't work for the main one.
I tried to put it above the rest of the rules - it did not help.
Answer the question
In order to leave comments, you need to log in
Actually, I will take out the answer from the comment:
Here is the only working config that removes multiple leading slashes:
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^(?:GET|POST)\ //+([^\ ]*)
RewriteRule .* https://%{HTTP_HOST}/%1 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question