url - URL 路径中的点是什么意思?

标签 url relative-path

question regarding a jQuery Ajax problem中,提问者试图在相对 URL 的开头使用 .。我建议他把它去掉,但不知道那里的点实际上有什么作用。

他的相对 URL 如下所示:

./delete-misc/test-ajax-code.php

我尝试查看 RFC,但没有成功。我知道点在命令行(Linux 或 Win)中的作用,它代表当前目录。

我想知道:这在 Internet 上的 URL 中是如何工作的?它有任何最佳实践用途吗?欢迎详细解释。

最佳答案

path segment .通常在相对路径引用的开头使用,并在 reference resolution 期间被删除。 ,即将相对 URI 引用解析为绝对 URI 的过程:

The path segments "." and "..", also known as dot-segments, are defined for relative reference within the path name hierarchy. They are intended for use at the beginning of a relative-path reference (Section 4.2) to indicate relative position within the hierarchical tree of names. This is similar to their role within some operating systems' file directory structures to indicate the current directory and parent directory, respectively. However, unlike in a file system, these dot-segments are only interpreted within the URI path hierarchy and are removed as part of the resolution process (Section 5.2).

Remove Dot Segments algorithms它描述了如何在特定的基本路径上下文中解释这些点段。

在您的情况下, ./delete-misc/test-ajax-code.phpdelete-misc/test-ajax-code.php 是等效的。但在某些情况下,相对路径可能会被误解为绝对 URI,例如在第一个路径段中有一个 :,例如 search:foo ,它与 ./search:foo 不同,因为前者是绝对 URI,而后者是相对 URI 路径。

关于url - URL 路径中的点是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6008829/

相关文章:

php - 网络语言, "directory/file.extension"与 "/directory/file.extension"

python - Pycharm 看不到相对路径中带有 ../的文件

reactjs - react PDF : Cannot use the packages to show static PDF file

c# - 在代码隐藏文件中设置报表查看器的 rdlc 文件的相对路径

android - 如何为单个 Facebook 消息帖子提供不同的多个 url 超链接

c# - .NET:使用 C# 列出 HTTP 流量 URL

javascript - 如何隐藏真实的图像路径(或撤销访问权限)?

java.net.SocketException : recvfrom failed: EBADF (Bad file descriptor) Android

lua - Lua中的相对文件路径?

php - 如何在 PHP 中检查域名是否为 CNAME