Search code examples
regexapache.htaccessmod-rewrite

Why is Apache removing multiple slashes?


This RewriteRule

RewriteRule ^test/(.*)$ test.php?url=$1

On this URL

mysite.com/test//one///two////three///

Is giving me this result

$1=url='one/two/three/'

I'm using easyphp if it matters and I like to know why is Apache removing multiple slashes internally without redirecting to correcred URL? and how can I disable or add a redirect to this behaviour?

Thank in advance


Solution

  • It seems multiple slashes are against the standard. As pointed out in this post, RFC 1630 says:

    PATH

    The rest of the URI follows the colon in a format depending on the scheme. The path is interpreted in a manner dependent on the protocol being used. However, when it contains slashes, these ust imply a hierarchical structure.

    /// does not imply a hierarchical structure - you'd have empty folder names. From that I would guess that Apache's behaviour is by design. (Nor would it be a good idea to use multiple slashes, as the result would be an invalid URL).

    I would use a different character instead.