Tim Liberty
Tim Liberty

Reputation: 2149

Urls redirect in .htaccess

My urls have http://test.com//123.html

Notice it has // from a 3rd party which is not under my control so I want to catch // urls and redirect it to single slash. I have this in my .htaccess

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

However it is not working and I see still // in the browser. Is there any issue in my code?

Upvotes: 0

Views: 60

Answers (1)

Samuel James
Samuel James

Reputation: 1536

Try this

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

Check this

Upvotes: 1

Related Questions