0

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?

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Tim Liberty
  • 2,099
  • 4
  • 23
  • 39

1 Answers1

1

Try this

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

Check this

Samuel James
  • 1,528
  • 16
  • 15