且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

主机名和URL语法

更新时间:2023-02-23 17:39:02

这些不是网址,因为它们缺少方案

These are not URLs, as they are missing a scheme.

假设您的意思是HTTP网址,它们将是:

Assuming that you mean HTTP URLs, they would be:

http://1.2.3.4.5.6.7/something
http://10.123.143.13333/something
http://1.2.3.4.5.6.7.com/something
http://some.host.name.com.org/something

RFC 3986定义主机子组件(HTTP(S)URI的RFC 2616如下)。

RFC 3986 defines the syntax of the host subcomponent for all URIs (and RFC 2616 for HTTP(S) URIs follows that).

主机您的示例URI的名称将是:

The host names of your example URIs would be:

1.2.3.4.5.6.7
10.123.143.13333
1.2.3.4.5.6.7.com
some.host.name.com.org

有效主机名遵循 IP-literal IPv定义的语法(在上面链接的部分中) 4address ,或 reg-name

Valid host names follow the syntax defined (in the section linked above) by IP-literal, IPv4address, or reg-name:


  1. 检查 IP-literal

作为 IP-literal 要求用方括号括起来( [ ... ] ),没有 IP-文字主机名。

As an IP-literal requires enclosing square brackets ([]), none are IP-literal host names.

检查 IPv4地址

作为 IPv4地址必须包含三个个字符, 1.2.3.4.5.6.7 1.2.3.4.5.6.7.com ,以及部分。 host.name.com.org 不能是 IPv4address 主机名。

As an IPv4address must contain exactly three . characters, 1.2.3.4.5.6.7, 1.2.3.4.5.6.7.com, and some.host.name.com.org can’t be IPv4address host names.

虽然 10.123.143.13333 有三个, 13333不是有效的 dec-octet ,所以它不是 IPv4地址

While 10.123.143.13333 has three ., "13333" is not a valid dec-octet, so it’s not an IPv4address.

检查 reg-name

您的所有示例均有效 reg-name 主机名,如 0-9 az 是允许的字符。

All of your examples are valid reg-name host names, as 0-9, a-z, and . are allowed characters.

请注意,意味着这些是DNS中的有效域名。 RFC 3986并未强制要求使用特定的注册名称查找技术。

Note that this does not mean that these are valid domain names in the DNS. RFC 3986 "does not mandate a particular registered name lookup technology".