带有文件扩展名(不带路径)的文件名是否被视为 URL?

Is a file name with its file extension (without the path) considered a URL?

我想知道 index.html 是不是亲戚 URL。

我知道 Website/Pages/index.html 是 URL。但是,如果它只是没有路径的文件名和文件扩展名呢?它还会被称为URL吗?

你的两个例子都是相对路径,不是urls。

相对url例子:

<A href="suppliers.html">Suppliers</A>
<IMG src="../icons/logo.gif" alt="logo">
<IMG src="image/logo.gif" alt="logo">

A relative URL (defined in [RFC1808]) doesn't contain any protocol or machine information. Its path generally refers to a resource on the same machine as the current document. Relative URLs may contain relative path components (".." means one level up in the hierarchy defined by the path), and may contain fragment identifiers.

SRC: http://www.w3.org/TR/WD-html40-970917/htmlweb.html


URL定义:

URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet. A URL has two main components: Protocol identifier: For the URL http://example.com , the protocol identifier is http . Resource name: For the URL http://example.com , the resource name is example.com.

SRC:https://docs.oracle.com/javase/tutorial/networking/urls/definition.html(这是一个url)


绝对路径:

/home/you/index.html

相对路径:

you/index.html
index.html

Absolute and relative paths

An absolute or full path points to the same location in a file system regardless of the current working directory. To do that, it must contain the root directory.

By contrast, a relative path starts from some given working directory, avoiding the need to provide the full absolute path. A filename can be considered as a relative path based at the current working directory. If the working directory is not the file's parent directory, a file not found error will result if the file is addressed by its name.

SRC:http://en.wikipedia.org/wiki/Path_(computing)

What a path relative URL is

而且,index.html可以是亲戚url。

When referring to a file that occurs in the same directory as the referring page, a URL can be as simple as the name of the file

如果你想从你的 about.html 页面 link 到你的 index.html 页面,只要它们在同一个目录中,你可以非常简单地做:

<a href="index.html">Index</a>

我认为您混淆的是绝对路径与相对路径。正如其他人所描述的,具有 绝对路径 的 URL 需要定义为:

  1. 协议:(http://)
  2. 域:(bobsjingles。)
  3. 扩展名:(edu)
  4. 目录路径:(/journeycovers)
  5. 片段:(/index.html)

http://bobsjingles.edu/journeycovers/index.html

绝对路径所做的(本质上)是指向机器上的 IP / 端口,您可以在特定协议 (http) 下发送请求,并获得预期的数据结果 (html .)

URL 是统一资源定位符的首字母缩写词,是对 Internet 上资源的引用(地址)。

话虽如此,带扩展名的文件名并不是 URL,因为它不足以确定文件在 Internet 上的位置。

但是,文件名及其扩展名可以被称为URI

URI 可以是定位器 (http://example.com) 或文件名 (example.txt),两者的组合就是 URL(仍然可以称为 URI)。

这里是完整的RFC3986供您参考。

Read this article 帮助您更多地了解 URI 和 URL 之间的区别以及一些示例

在像 http://example.com/index.html 这样的 HTTP URL 中,/index.html URL 的路径。

HTTP URL不"know"也不关心文件名或文件扩展名。

/index.html/index_html/index/index/foo/html/foooo 等路径在概念上没有区别。 (另一方面,如果请求 URL,服务器可能会使用各种约定,例如在文件扩展名后附加一个点,以执行 某事。)