Monday , February 3 2025

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 iryna

I'm Iryna, a web developer from Ukraine with a decade of experience solving complex technical challenges in the world of freelance. Throughout my career, I've worked on everything from troubleshooting server-side issues and optimizing website performance to enhancing user interfaces. On this blog, I share detailed solutions to the technical problems I’ve encountered and methods that have worked best for me. In addition to my technical expertise, I’m also passionate about digital drawing. I hope the tutorials and insights I provide here will help both fellow developers and creatives alike in their own projects.

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 *