English 中文(简体)
URL部分的名称和最长期限
原标题:Names and maximum lengths of the parts of a URL

In this URL:

http://www.subdomain.domainname.abc.xyz.com.us/directory/filename.extension
  1. What is the name of each part?
  2. What is maximum length of each part? e.g. subdomain, domain name, top-level domain…
问题回答

https://en.wikipedia.org/wiki/Subdomain#Overview” rel=“noreferer”>Subdomain

  1. What is the name of each part?

http://en.wikipedia.org/wiki/Root_domain”rel=“noretinger”>。 例如,West.example.com and east.example.com are subdomains of the example.com area, which in another is a subdomain of the com top-level > (TLD)。 “子”表示相对依赖,而不是绝对依赖:例如,<代码>wikipedia.org。 包括<代码>org域和<编码>en.wikipedia.org的子域。 域名:<代码>wikipedia.org。

  1. What is maximum length of each part? e.g. subdomain, domain name, top-level domain…

In theory this subdivision can go down to 127 levels deep, and each DNS label can contain up to 63 characters, as long as the whole domain name does not exceed a total length of 255 characters. But in practice most domain registries limit at 253 characters.

TLDR - The Names

Given foo://example.com:8042/over/there?name=ferret#nose, your components can break down as follows, according to RFC3986 (January 2005)...

     foo://subdomain.example.com:8042/over/there?name=ferret#nose
     \_/  \________/                /\_________/ \_________/ \__/
      |       |                          |            |        |
          \___|_____________________/
   scheme   label       authority       path        query   fragment
   (AKA:                (AKA:
   protocol)            (domain)

TLDR - The Maximum Lengths

  • Label / Subdomain: 63 characters maximum.
  • Domain: 253 characters maximum
  • Total URL: 2,000 characters maximum

The Details

现在,请在您的“URLcode”替代版本上删除这一句:http://www.subdomain.domain.domainname.com/directory/filename.extension?name=ferret#nose :

Protocol

  • http:// : The scheme, or protocol.
    • Max Length: No limits are imposed, but these are typically created by the IETF, so the longest, RFC d scheme would be the max, which I see as prospero, 8 characters. However! You can make your own protocol and have it be any reasonable length, though I would probably not exceed 255 characters. For instance, file:/ in Chrome will show the file, samba:/ in Linux will launch the Samba application and access the resource, etc., etc..
    • Source: RFC1738 (December 1994)
    • Quote: "Notes on particular protocols follow. The schemes covered are: ftp, http, gopher, mailto, news, nntp, telnet, wais, file, prospero."

SubDomain

  • www, subdomain : www is just a popular sub-domain that is superfluous today.
    • Max Length: 63 characters
    • Source: RFC1035 (November 1987)
    • Quote: "Labels must be 63 characters or less."

Domain

  • domainname.com : Your "domain," not any level of it but the full domain.
    • Max Length: 253 characters if you care about E-mail (max limit of the to field in SMTP is 255 characters, leaving you with a@(253-char-domain) as the longest possible domain in an email; 255 if you don t mind E-mail not working
    • Source: RFC2821 (October 2008), RFC5321 (October 2008), RFC821 (August 1982)
    • Quote:

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)

Second-Level Domain

  • domainname : Your second-level domain.
    • Same limits and source as subdomains.

Top-Level Domain

  • com : Your top-level domain (TLD). This may also contain a period in it, like co.uk.
    • Max Length: These are established by RFC s by the IETF. The max length will be whatever the longest TLD exists. For instance, RFC6927 reserved the domain .XN--MGBERP4A5D4AR for Saudi Arabia.
    • Source: RFC920 (October 1984)
    • Quote: "The initial top level domain names are: ARPA, GOV, EDU, COM, MIL, ORG."

Path

  • directory/filename.extension : This is your path.
    • Max Length: Infinite, but in practice, please stick to URLs no longer than 2,000 characters, as not all browsers can understand the concept of infinite.
    • Source: RFC3986 (January 2005), RFC2616 (June 1999), RFC7230
    • Quote:

Servers MUST 能够处理URI的任何服务资源,SHOULD 能够处理URIs的无约束长度。

"This specification does not limit the scope of what might be a resource..." (RFC3986);

* “建议所有吉大港定居人士和受援者至少支持申请线长度8 000英亩(RFC7230)

Query and Fragment

  • name=ferret : This is a GET parameter, in the form of field=value.
  • #nose : This is the fragment, which can be used to anchor to a specific section of an HTML document using the <a name="nose" /> HTML.
    • Max: As described in the section above on the path, the total path, query, and fragment should not exceed 2,000 characters.
    • Source: RFC3986 (January 2005)
    • Quote:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

回答问题1:

简而言之,《世界人权倡议》将探讨这样的问题:

http://www.mywebsite.com

It s easier to explain right to left:

  • com is the top level domain (TLD)
  • mywebsite is the domain, but would typically include the TLD when describing, e.g. mywebsite.com
  • www is a subdomain
  • http:// is the protocol used to access the resource

要使事情更加混乱,许多顶级领域实际上是两个领域,例如:co.uk。

So, another example would be:

https://aaa.bbb.ccc.mywebsite.co.uk
  • co.uk is the TLD
  • mywebsite is the domain
  • ccc is a subdomain
  • bbb is a sub-subdomain, or you could say a subdomain of ccc.mywebsite.co.uk
  • aaa is a sub-sub-subdomain, or you could say a subdomain of bbb.ccc.mywebsite.co.uk

在TLD之后,但在档案之前,任何名字都被称作通路,例如:

https://www.mywebsite.com/this/is/a/path/to/resource/filename.txt

在上述例子中,姓名。 t通常称为一种资源(尽管有些人说整个线是资源,因为你没有档案名称)。





相关问题
Using PHP to find part of a URL

Take this domain: http://www.?.co.uk/elderly-care-advocacy/mental-capacity-act-advance-medical-directive.html How could i use PHP to find the everything between the first and second slash regardless ...

Domains & Foreward Slash

This is rather difficult to explain so please bear with me. We will be hosting 4 websites on our server and the plan is to have each site sit under its own domain: site-a.com site-b.com sub1.site-b....

Encoding of window.location.hash

Does window.location.hash contain the encoded or decoded representation of the url part? When I open the same url (http://localhost/something/#%C3%BC where %C3%BCtranslates to ü) in Firefox 3.5 and ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

采用网路服务方法

我撰写了一个网络服务,期望一个参数(所谓的“hlink”)成为一种ur。 在使用网络服务之前,URLEncode 所涉参数(“hlink”)。 然后我打电话......。