FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » extracting the root domain from a URL
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: extracting the root domain from a URL [message #171654 is a reply to message #171642] Fri, 14 January 2011 10:27 Go to previous messageGo to previous message
Jonathan Stein is currently offline  Jonathan Stein
Messages: 43
Registered: September 2010
Karma:
Member
Den 13-01-2011 22:50, Mike skrev:

> Given any valid URL, I'd like to extract the root domain like this:
>
> http://www.site.com = site.com
> http://xxx.yyy.site.com = site.com
> http://subdomain.site.com = site.com
> http://www.site.com.tw = site.com.tw
> http://xxx.yyy.site.com.asia = site.com.asia
> http://subdomain.site.com.af = site.com.af

If you need a fast lookup, you'll probably need to maintain a database
with rules for each TLD you intend to support.

Otherwise you could go for a series of "whois" lookups. If whois
succeeds for "site.com.af" but fails for "subdomain.site.com.af", then
"site.com.af" was probably what you was looking for.

- Maybe a combination with a database or hard coded rules for the most
used TLDs.

Regards

Jonathan
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: printing for dot matrix printers
Next Topic: having better solution to promote your products.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 07:22:16 GMT 2024

Total time taken to generate the page: 0.04748 seconds