URL 路径中的点是什么意思? [英] What does a dot mean in a URL path?

查看:55
本文介绍了URL 路径中的点是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 jQuery Ajax 问题的问题中,提问者试图在相对 URL 的开头使用 ..我建议他删除它,但不知道那里的一个点实际上做了什么.

In a question regarding a jQuery Ajax problem, the asker was trying to use a . in the beginning of a relative URL. I advised him to remove it, but have no idea what a dot actually does there.

他的相对 URL 如下所示:

His relative URL looked like this:

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

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

I tried looking in the RFCs, without success. I know what the dot does in command line (either Linux or Win), it represents the current directory.

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

I'd like to know: how does this work on the Internet in a URL? Does it have any best-practice uses? Detailed explanations are most welcome.

推荐答案

路径段. 通常用在相对路径引用的开始处,并在 引用解析,即将相对 URI 引用解析为绝对 URI 的过程:

The path segment . is typically used at the begin of relative path references and are removed during the reference resolution, i.e. the process of resolving a relative URI reference to an absolute URI:

路径段."和..",也称为点段,是为路径名层次结构中的相对引用而定义.他们旨在用于相对路径引用的开头(第 4.2 节)表示层次结构中的相对位置名字树.这类似于他们在某些运营中的作用系统的文件目录结构以指示当前目录和父目录,分别.但是,与文件中不同系统,这些点段仅在 URI 路径中解释层次结构,并作为解析过程的一部分被删除(Section5.2).

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).

删除点段算法 描述如何在特定的基本路径上下文中解释这些点段.

There is Remove Dot Segments algorithms that describes how these dot segments are to be interpreted in a certain base path context.

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

In your case both ./delete-misc/test-ajax-code.php and delete-misc/test-ajax-code.php are equivalent. But there are cases where a relative path can be misinterpreted as an absolute URI, e.g. having a : in the first path segment like search:foo that is different to ./search:foo as the former is an absolute URI while the latter is a relative URI path.

这篇关于URL 路径中的点是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆