Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

regex - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...