在这个网址中:
http://www.subdomain.domainname.abc.xyz.com.us/directory/filename.extension
最佳答案
TLDR - 名字
给定 foo://example.com:8042/over/there?name=ferret#nose
,根据 RFC3986,您的组件可以分解如下(2005 年 1 月)...
foo://subdomain.example.com:8042/over/there?name=ferret#nose
\_/ \________/ /\_________/ \_________/ \__/
| | | | |
\___|_____________________/
scheme label authority path query fragment
(AKA: (AKA:
protocol) (domain)
TLDR - 最大长度63
字符数上限。 253
最大字符 2,000
最大字符 细节
现在,让我们分解一下给定 URL
http://www.subdomain.domainname.com/directory/filename.extension?name=ferret#nose
的替代版本。 :协议(protocol)
http://
: 方案或协议(protocol)。prospero
, 8
人物。然而!您可以制定自己的协议(protocol),并将其设置为任何合理的长度,但我可能不会超过 255
人物。例如,file:/
在 Chrome 中将显示文件,samba:/
在 Linux 中将启动 Samba 应用程序并访问资源等。子域
www
, subdomain
: www
只是一个流行的子域,今天是多余的。63
字符 领域
domainname.com
:您的“域”,不是它的任何级别,而是完整的域。253
字符,如果您关心电子邮件(SMTP 中 to
字段的最大限制是 255
字符,留下 a@(253-char-domain)
作为电子邮件中可能的最长域;255
如果您不介意 E -邮件不工作The maximum total length of a domain name or number is 255 characters. (RFC2821, RFC5321)
[The email address format is]
<mailbox> ::= <local-part> "@" <domain>
(RFC821)
二级域名
domainname
: 你的二级域名。顶级域
com
: 您的顶级域 (TLD)。这也可能包含一个句点,如 co.uk
..XN--MGBERP4A5D4AR
为沙特阿拉伯。 小路
directory/filename.extension
: 这是你的路。Infinite
, 但实际上,请坚持使用不超过 2,000
的 URL字符 ,因为并非所有浏览器都能理解无限的概念。 "Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length..." (RFC2616);
"This specification does not limit the scope of what might be a resource..." (RFC3986);
*"It is RECOMMENDED that all HTTP senders and recipients support, at a minimum, request-line lengths of 8000 octets." (RFC7230)
查询和分片
name=ferret
: 这是 GET
参数,格式为field=value
. #nose
:这是片段,可用于使用 <a name="nose" />
锚定到 HTML 文档的特定部分HTML。2,000
人物。
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
关于url - URL 各部分的名称和最大长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10552665/