为什么 Apache 删除多个斜杠? [英] Why is Apache removing multiple slashes?
问题描述
这个重写规则
重写规则 ^test/(.*)$ test.php?url=$1
在这个网址上
mysite.com/test//one///two////three///
给我这个结果
$1=url='one/two/three/'
如果重要的话我正在使用easyphp并且我想知道为什么Apache在内部删除多个斜杠而不重定向到正确的URL?以及如何禁用或添加重定向到此行为?
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?
提前致谢
推荐答案
似乎多个斜线不符合标准.正如这篇文章,RFC 1630 说:
It seems multiple slashes are against the standard. As pointed out in this post, RFC 1630 says:
路径
URI 的其余部分跟在冒号后面,格式取决于方案.路径的解释方式取决于正在使用的协议.但是,当它包含斜杠时,这些只能暗示一个层次结构.
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.
///
并不意味着分层结构 - 您将拥有空文件夹名称.由此我猜想 Apache 的行为是设计使然.(使用多个斜杠也不是一个好主意,因为结果将是一个无效的 URL).
///
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).
我会改用不同的字符.
这篇关于为什么 Apache 删除多个斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!