Friday , December 20 2024

301 redirect – remove slashes after domain name

If you need to make ‘https://domain.com/////////////’ links like this ‘https://domain.com/’, you can copy the following solution to .htaccess. In this case, the redirect will be instant (not multistep).

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
RewriteRule .* https://%{HTTP_HOST}/%1 [R=301,L]

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

Removing type=’text/javascript’ and type=’text/css’ from Joomla for validator

At first, as a person from the 17th century, I tried stupidly to remove these …

Leave a Reply

Your email address will not be published. Required fields are marked *