为什么 Apache 要删除多个斜杠?
此 RewriteRule
RewriteRule ^test/(.*)$ test.php?url=$1
在此 URL
mysite.com/test//one///two////third// /
给了我这个结果
$1=url='one/two/third/'
我正在使用 easyphp 如果它很重要,我想知道 为什么 Apache 删除多个内部斜杠而不重定向到正确的网址?以及如何禁用或添加对此行为的重定向?
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来多重斜线是违反标准的。正如这篇文章,RFC 1630 说:
///
并不暗示分层结构 - 您将拥有空文件夹名称。由此我猜测 Apache 的行为是设计使然。 (使用多个斜杠也不是一个好主意,因为结果将是一个无效的 URL)。我会使用不同的角色来代替。
It seems multiple slashes are against the standard. As pointed out in this post, RFC 1630 says:
///
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.