Skip to main content
14 events
when toggle format what by license comment
Jan 7, 2020 at 15:22 comment added GrandOpener I'm afraid I cannot agree with redirects being a general purpose replacement here. It is very important to note that a redirect will not "just work" if verbs other than GET are being used. In that case, either the double slashes need to be fixed on the client side, or the webserver needs to handle them similarly to what Apache is doing.
Apr 13, 2017 at 12:33 history edited CommunityBot
replaced http://webmasters.stackexchange.com/ with https://webmasters.stackexchange.com/
May 5, 2016 at 18:22 history edited Simon Hayter CC BY-SA 3.0
deleted 23 characters in body
Apr 5, 2014 at 1:24 comment added Abel @josh3736, sorry I misunderstood. I thought you meant that a server may not auto-collapse slashes in the comment above. But a server can do that (because it is allowed to return the same source from different urls). A client cannot (you explain that nicely in your post). You suggest in your post also that it is better to send a redirect instead, I agree too, it is neater, though not required by any spec.
Apr 4, 2014 at 17:22 comment added josh3736 @Abel: That's something different; of course you can return the same content on different URIs if you choose. I'm saying that automatically collapsing slashes is not spec-compliant because the spec says that every slash is significant.
Apr 4, 2014 at 14:14 comment added Abel @josh3736, on I'd argue that RFC 2396 does forbid a server from returning the same resource. This is actually not true. The RFC specifically allows the same resource to be returned for different URIs. It is part of separating the naming scheme from the resource retrieval. http://x.y/z and http://a.b/c may retrieve the exact same document, even though the URIs are 100% different. Same rule applies to treatment of double slashes. Whether you want it, or configure it that way, is a different question altogether.
Apr 9, 2012 at 21:59 comment added Bruno @josh3736, you're right these URLs should be treated as different, but collapsing double slashes into one has nothing to do with the URL spec, but how the web server chooses to map this to the file system. This is not specified and is implementation dependent. Multiple resources (in the distinct URIs sense) may be automatically mapped to the same file in the backend (like symbolic links would). It makes sense to do so when the resources are files/directory. It wouldn't if it's executed by a script (e.g. /index.php/something//something/).
Apr 9, 2012 at 20:21 comment added josh3736 ...and anyway, I'd argue that RFC 2396 does forbid a server from returning the same resource by auto-collapsing slashes because the spec says every slash is significant. Automatically ignoring consecutive slashes is in violation of that spec. (It's one thing if someone programmed their server to do that, even if doing so would be silly. However, servers doing this by default is incorrect.)
Apr 9, 2012 at 20:14 comment added josh3736 @IlmariKaronen: It absolutely is incorrect behavior because (1) this behavior automatically creates an infinite number of potential duplicate references to a single resource (which, if not in violation of the letter of any spec, certainly violates the spirit), and more practically (2) it "breaks" relative-path handling in browsers that do properly count the empty string in a//b as a directory (see the stylesheet example above).
Apr 9, 2012 at 19:44 comment added Ilmari Karonen It's not incorrect behavior: a/b and a//b indeed are two distinct URL paths, but nothing forbids the server from returning the same resource for both of them if it wants. I do agree with you, however, that in practice returning a 301 redirect would seem more useful.
Jan 28, 2011 at 13:51 comment added josh3736 @Ward: Admittedly, I'm not an Apache expert; that rewrite rule was in one of the top Google results for "url double slash". My assumption is that it will operate recursively -- you'll get redirects from /a///b//c/ -> /a//b//c/ -> /a/b//c/ -> /a/b/c/. Of course, that's 4 HTTP roundtrips (which is horribly inefficient), but this is a fix for something that shouldn't be happening anyway.
Jan 28, 2011 at 11:18 comment added Ben Hoffman +1 - Thanks for the extra info. I didn't think of it that way!
Jan 28, 2011 at 0:16 comment added Ward Muylaert Wouldn't it be better to have your mod_rewrite solution take into account 3, 4, ... slashes too? Something along the lines of /{2,}? (Assuming Apache allows that kind of quantifier, I'm not too familiar with it)
Jan 27, 2011 at 21:28 history answered josh3736 CC BY-SA 2.5