http - 如果 ".com"之后有一个点,它是一个有效的 URL 吗?

标签 http url dns

我遇到了一些 URL,它们在 .com 之后也带有或不带有点/句点,而有些则没有。

例如:

www.example.com.

如果在 .com 之后添加一个点/句点,URL 应该正常呈现还是应该转到 404 页面?

最佳答案

正如评论中所说,这很棒resource ,解决了您的许多查询,包括以下特定于您的查询的部分:

Fully-Qualified Domain Names

When I double-click a Bonjour (DNS-SD) Name in a web browser like Safari, the resulting URL has a hostname with a dot at the end. Is this a bug?

No, the dot at the end is correct.

You can try it here. Try adding a dot at the end of www.dns-sd.org, as shown in the subtitle at the top of this page, and you should still get the same page.

It's a little-known fact, but fully-qualified (unambiguous) DNS domain names have a dot at the end. People running DNS servers usually know this (if you miss the trailing dots out, your DNS configuration is unlikely to work) but the general public usually doesn't. A domain name that doesn't have a dot at the end is not fully-qualified and is potentially ambiguous. This was documented in the DNS specification, RFC 1034, way back in 1987:

Since a complete domain name ends with the root label, this leads to a printed form which ends in a dot. We use this property to distinguish between:

  • a character string which represents a complete domain name (often called "absolute"). For example, poneria.ISI.EDU.

  • a character string that represents the starting labels of a domain name which is incomplete, and should be completed by local software using knowledge of the local domain (often called "relative"). For example, "poneria" used in the ISI.EDU domain.

How this affects web browsing

The people defining the HTTP protocol understood this issue, and RFC 1738 specifies clearly that the part of a URL is supposed to contain a fully qualified domain name:

3.1. Common Internet Scheme Syntax

  //<user>:<password>@<host>:<port>/<url-path>

host
  The fully qualified domain name of a network host

不幸的是,实现网络浏览器客户端的人似乎并不理解这意味着什么。当您访问一个网站时,在应用 DNS 用户的搜索列表从部分名称。例如,以下是用户引用主机“www.example.com”的三种不同方式。

  • www.example.com. — 绝对域名
  • www.example.com — 相对域名,在应用“.”后总是隐含在每个人的 DNS 搜索列表中,变成 www.example.com。
  • www 在 DNS 搜索列表中使用“example.com”——用户键入“www”并获取
    www.example.com.

当发送 Host: 参数到网络服务器时,网络浏览器客户端输入用户输入的内容(www.example.com.www .example.comwww),而不是客户端最终实际在 DNS 中查找的内容(www.example.com. 在所有三种情况下) . 不幸的是,Apache 网络服务器(至少在某些版本中)无法识别所有这三个名称只是引用同一主机的三种不同方式。

如果您是使用 Apache“VirtualHost”指令或类似指令设置网站的网站管理员,您需要有一个 ServerAlias 行,列出用户为访问该网站可能键入的所有内容(通常是第一个标签,不带尾随点的全名,以及带尾随点的全名,如上例所示)。

关于http - 如果 ".com"之后有一个点,它是一个有效的 URL 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36931853/

相关文章:

html - <link ...> 中缺少 http(s) - 有效吗?

javascript - ENTER 在 POST 上从\n 转换为\r\n

php - 使用php从json url获取数据?

url - 浏览器支持 Unicode URL

c - 检测到域的连接

http - 给出资源错误的 Tomcat 应用程序 Web.xml 自定义过滤器已移动;过滤器将 https 重定向到 http

c# - 收藏已修改;枚举操作可能不会执行随机弹出 - HTTP?

dns - Kestrel 是否支持 urls/hostnames,或者它只能监听一个端口?

url - 用于表示 URL 的 MIME 媒体类型(内容类型)?

c# - 解析变量 URI(RegEx、Uri、字符串函数?)c#