In this URL:
http://www.subdomain.domainname.abc.xyz.com.us/directory/filename.extension
- What is the name of each part?
- What is maximum length of each part? e.g. subdomain, domain name, top-level domain…
The Wikipedia entry for Subdomain answers both questions:
A subdomain is a domain that is part of a larger domain; the only domain that is not also a subdomain is the root domain. For example,
west.example.com
andeast.example.com
are subdomains of theexample.com
domain, which in turn is a subdomain of the com top-level domain (TLD). A "subdomain" expresses relative dependence, not absolute dependence: for example,wikipedia.org
comprises a subdomain of theorg
domain, anden.wikipedia.org
comprises a subdomain of the domainwikipedia.org
.
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.
To answer question 1:
A simple URI would look something like:
http://www.mywebsite.com
It's easier to explain right to left:
Just to make things a little more confusing, many top level domains are actually 2 domains, such as .co.uk
So, another example would be:
https://aaa.bbb.ccc.mywebsite.co.uk
Anything after the TLD but before the filename is called the path, e.g:
https://www.mywebsite.com/this/is/a/path/to/resource/filename.txt
In the above example filename.txt is usually called a resource (although some would say the whole line is the resource, because you don't always have a filename).
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)
63
characters maximum.253
characters maximum2,000
characters maximumNow, let's break this down for an alternate version of your given URL http://www.subdomain.domainname.com/directory/filename.extension?name=ferret#nose
:
http://
: The scheme, or protocol.
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..www
, subdomain
: www
is just a popular sub-domain that is superfluous today.
63
charactersdomainname.com
: Your "domain," not any level of it but the full domain.
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 workingThe 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
: Your second-level domain.
com
: Your top-level domain (TLD). This may also contain a period in it, like co.uk
.
.XN--MGBERP4A5D4AR
for Saudi Arabia.directory/filename.extension
: This is your path.
"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
: 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.
2,000
characters.
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]