HTTP/FTP : Does trailing slash in URL mean another resource

标签 http url ftp

我有两个网址:

http://example.com/foo

http://example.com/foo/

它们是不同的 URL 还是相同的?同样的问题是关于 FTP 协议(protocol) (ftp://example.com/foo[/])

最佳答案

在URI标准中,相关部分是Normalization and Comparison :

  1. 在完成 simple string comparison 之后, 这些 URI 是不等价的。

  2. 申请后syntax-based normalization , 这些 URI 是不等价的。

  3. scheme-based normalization ,您必须引用 http/httpsftp URI 方案的规范,并检查是否定义了任何特定于方案的规则:

  1. protocol-based normalization ,您必须考虑重定向之类的东西(在 http 的情况下)。

tl;dr:URI 相同。


请注意,HTTP(S) URI 中的空路径不是这种情况,如上面链接的部分所定义:

[…] an empty path component is equivalent to an absolute path of "/" […]

所以下面的 URIs 等价的:

http://example.com/

http://example.com

顺便说一句,对于基于协议(protocol)的规范化,标准以您的案例为例:

[…] For example, if they observe that a URI such as

http://example.com/data

redirects to a URI differing only in the trailing slash

http://example.com/data/

they will likely regard the two as equivalent in the future. […]

关于HTTP/FTP : Does trailing slash in URL mean another resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39717742/

相关文章:

php - file_get_contents 发出警告

Java:使用库将文件从 URL 直接上传到 FTP 服务器

java - 如何在@RequestParam中传递符号&?

rest - 在具有应该唯一的指定属性的记录已经存在的情况下,可以使用 409 HTTP 代码吗?

http - 如何在不发送响应的情况下终止 http 请求?

javascript - 可以通过 URL 控制 JavaScript 函数

java - 如何使用java从ftp服务器删除文件?

java - Java 代码中的 commons-net FTPSClient 错误

python3, ftplib storlines 错误

Java:ConnectException/无法找到或加载主类