Jay Kareliya
Jay Kareliya

Reputation: 770

Remove forward slashes from url by htaccess

Trying to remove double slashes after domain. The following mod_rewrite expressions seem to work for URLs such as http://example.com//login, but do not work for domain//

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

I want to convert URL from :

 http://example.com//login

To

 http://example.com/login

Would you please give me proper suggestion about how to remove double slashes from url?

Any kind of help would be highly appreciated.

Thanks in advance.

Upvotes: 0

Views: 473

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

Try :

RewriteEngine on

RewriteRule ^/+(.*)$ /$1 [L,R]

You can also use RedirectMatch

RedirectMatch ^//+(.*)$ /$1

Upvotes: 1

Related Questions