Removing multiple slashes

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 28
Joined: 29 Aug 2012, 06:15

Removing multiple slashes

18 Sep 2014, 15:57

Hi,

How can we use ISAPIRW 3 to remove multiple trailing slashes from URLs, like these for example:

http://www.ourdomain.com///
http://www.ourdomain.com///Folder/
http://www.ourdomain.com///Folder///

The URLs seem to work with the extra slashes, but how can we remove them so that /// becomes / ?

Advice appreciated, I could find no similar questions in the forum.

Thanks,
Mark

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Removing multiple slashes

19 Sep 2014, 11:00

Hello,

And there probably isn't one like this...
We can only try to play around like this:

Code: Select all
RewriteRule ^([^/]+)(:?/)?//(.+)$ /$1/$2 [NC,LP,L]


So that it'd match anything before the first '/' and if it sees 2 or 3 of them it'd redirect. This would repeat in the loop until; nothing else is left.

Regards

User avatar
Posts: 28
Joined: 29 Aug 2012, 06:15

Re: Removing multiple slashes

20 Sep 2014, 09:24

Hi, alas that rewriterule did nothing at all :|

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Removing multiple slashes

22 Sep 2014, 22:50

Hi,

Could you, please, provide the rewrite.log for the testing request?
Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html

Regards

User avatar
Posts: 28
Joined: 29 Aug 2012, 06:15

Re: Removing multiple slashes

30 Sep 2014, 06:58

Hi,

I enabled logging but nothing was saved. There is just an error log.

Your rewrite works in some cases:

http://www.ourdomain.com//folder/ NO
http://www.ourdomain.com///folder/ NO
http://www.ourdomain.com///folder WORKS!

So if there is a missing slash on end, it works, but middle of URL doesn't work.

Btw your own domain does it too:

http://www.helicontech.com///
http://www.helicontech.com///zoo/
etc

SEO audits pick up the multiple slashes immediately, so I am surprised this rewrite is not more commonly asked for - it's a basic requirement I'd say.

Many thanks,
Mark

User avatar
Posts: 28
Joined: 29 Aug 2012, 06:15

Re: Removing multiple slashes

30 Sep 2014, 07:11

I fixed it using code in the end, by scanning the CGI X_REWRITE_URL and then 301'ing to the correct URL with no slashes, works like a charm now and the SEO audit passes too :) I'd prefer a rewrite though!

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 5 guests