Page 1 of 1

Spliting a hostname

Posted: Thu Jul 23, 2009 10:50 am
by alex.barylski
I know of many URI classes (including the one in Zend) however none seem to break a hostname into smaller units for you, particularly sub-domain, domain and TLD.

Initially it may seem possible to just split the domain on '.' and be done with it, however what about domains where there are arbitrary number of sub-domains and TLD?

Is this even possible? I have seen sites that seem to offer multiple sub and TLD's, such as:

*.mb.ca - is popular for goverment web sites (mb.ca appears to be the TLD?)

I have also seen commercial web sites do something like

winnipeg.mb.domain.ca (winnipeg.mb appears to be the sub-domains)

If this is possible, knowing this makes just simply splitting on periods risky. What alternatives do I have?

Do I acquire a list of TLD's and figure out the TLD, the domain and sub-domains from there?

I realize it's very unlikely for a web site to have more than one sub-domain but it could happen so I'd rather build with that awareness.

Any ideas?

Re: Spliting a hostname

Posted: Thu Jul 23, 2009 11:01 am
by Jenk
'.' is the splitter. There are no TLD's with fullstops/periods in them. Prime example is the UK's '.co.uk' The TLD is actually .uk and the .co is a sud-domain of that TLD. (Hence why we have .gov.uk, .mod.uk, etc.)

Re: Spliting a hostname

Posted: Thu Jul 23, 2009 11:50 am
by alex.barylski
EDIT | Just looked at GoDaddy...they seem to have TLD's for sale with periods (ie: .net.cn) why would they offer that and not just .cn? Does this mean GoDaddy has purchased the domain net.cn and is simply selling off it's sub-domains?

OK thats what I figured but wasn't sure about and figured I'd ask.

So TLD's are a list I can get from GoDaddy or similar source and the last element in a split would be the TLD, one up would be the domain and anything further are sub-domains?

Thanks for the heads up :)

Re: Spliting a hostname

Posted: Thu Jul 23, 2009 1:05 pm
by VladSun
As far as I remember, one is not allowed to register a domain name which is:
- shorter than 3 symbols (WTF??? hp.com ???);
- is the same as one of the top-level domains (e.g. org.com)

It's up to the ccTLD registrar to decide whether a second level domains will be used (e.g. co.uk) or not.

Re: Spliting a hostname

Posted: Thu Jul 23, 2009 1:43 pm
by jayshields
VladSun wrote:- shorter than 3 symbols (WTF??? hp.com ???);
Nah that's not true. There are many exceptions to that rule.

http://en.wikipedia.org/wiki/Single-let ... el_domains

One which is being advertised on UK TV loads now is lv.com.

Re: Spliting a hostname

Posted: Thu Jul 23, 2009 2:03 pm
by VladSun
jayshields wrote:
VladSun wrote:- shorter than 3 symbols (WTF??? hp.com ???);
Nah that's not true. There are many exceptions to that rule.

http://en.wikipedia.org/wiki/Single-let ... el_domains
In fact, it's true:

http://en.wikipedia.org/wiki/Single-let ... el_domains
Two-letter domain names are also restricted to prevent confusion with country-codes. However, this restriction was enacted long after domain names became popular, so there are many existing registrations in the old top-level domains, though they are prevented in most of the new ones such as .info.


:P

Re: Spliting a hostname

Posted: Thu Jul 23, 2009 3:10 pm
by alex.barylski
Stupid authorities...how does that Pennywise song? Anyone know what song I'm talking about? :P 8)

Re: Spliting a hostname

Posted: Fri Jul 24, 2009 4:07 am
by Jenk
PCSpectra wrote:EDIT | Just looked at GoDaddy...they seem to have TLD's for sale with periods (ie: .net.cn) why would they offer that and not just .cn? Does this mean GoDaddy has purchased the domain net.cn and is simply selling off it's sub-domains?

OK thats what I figured but wasn't sure about and figured I'd ask.

So TLD's are a list I can get from GoDaddy or similar source and the last element in a split would be the TLD, one up would be the domain and anything further are sub-domains?

Thanks for the heads up :)
GoDaddy are telling a white lie. They are the domains that GoDaddy are permitted to sell, not the TLD's..

http://en.wikipedia.org/wiki/List_of_In ... el_domains

Re: Spliting a hostname

Posted: Fri Jul 24, 2009 6:30 am
by SeaJones
RE: Two letter domains

It *used* to be the case that domains registered through InterNIC (.com .org etc) could only have two letters if one was a number. Some registrars never enforced this, some actually still do. InterNIC will still delete stuff that they consider to be conflicting or confusable with other domains especially country-code SLDs, although they barely ever seem to bother. The rule seem to basically be "don't take the <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>".

All of this said, HP.com was registered when it should've been impossible, and the InterNIC could've happily deleted it, but it didn't. If they had had an initialism that conflicted with a country code they might've had more trouble.

A good example of this kind of loosely enforced rule system is the .name domain type, which according to rules should be first.last.name, but loads of people don't do that, and there is no requirements for the two names to actually be yours. Thousands of .name domains are registered with only one name attached.

Nominet, on the other hand, can be quite strict. But even then only when they can be arsed.

Re: Spliting a hostname

Posted: Fri Jul 24, 2009 7:40 am
by Weirdan
PCSpectra, for a list that uses layman's definition (where '.co.uk' is a tld) you may consult FF source code - it maintains that list to decide whether to allow crossdomain cookies (for example it would allow a cookie for .example.com to be set from a.example.com, but would not allow a cookie from a.co.uk to be set for .co.uk).