regex - match multiple slashes in url, but not in protocol -
i try catch multiple slashes @ ende or inside of url, not slashes (which 2 or more), placed after protocol (http://, https://, ftp:// file:///)
i tried many findings in similar so-threads, ^(.*)//+(.*)$
or [^:](\/{2,})
, or ^(.*?)(/{2,})(.*)$
in http://www.regexr.com/, https://regex101.com , http://www.regextester.com/. nothing worked clear me.
its pretty weird, can't find working example - goal isn't such rar. share working regex?
here rule can use in site root .htaccess strip out multiple slashes anywhere input urls:
rewriteengine on rewritecond %{the_request} // rewriterule ^.*$ /$0 [r=301,l,ne]
the_request
variable represents original request received apache browser , doesn't overwritten after execution of rewrite rules. example value of variable get /index.php?id=123 http/1.1
.
pattern inside rewriterule
automatically converts multiple slashes single one.
Comments
Post a Comment