Portal Home > Knowledgebase > Articles Database > Determing if a domain is a subdomain in PHP
Determing if a domain is a subdomain in PHP
Posted by GregVernon, 01-13-2010, 12:13 AM |
Hey everyone,
I'm trying to filter out particular "free" domains, namely co.cc, from being allowed into the HostLaunch review database.
I know I could manually set filters, but I'm curious is there is native way in PHP to determine if a domain is really a subdomain (such as *.co.cc) or an actual domain.
|
Posted by Jamza, 01-13-2010, 12:36 AM |
I'm not sure what you mean by native, if you mean as in a function. I don't think there is one sorry.
You could always do a whois lookup on a domain, if it returns registrant information and nameservers etc It is a subdomain. Co.cc returns this. Whereas a whois lookup on Co.uk returns no domain information as it is a TLD and not technically registered to anyone.
|
Posted by GregVernon, 01-13-2010, 01:00 AM |
Yeah, I was thinking that. I'm concerned about resource usage, though. I'm using a shared host at the moment, so even when I store a valid or invalid result for each tld, it will take up resources I don't necessarily want to take up.
I think for now I'll just need to ban fake tld's in the software.
|
Posted by bigfan, 01-13-2010, 09:51 AM |
No, co.uk is a second-level domain; uk is the TLD, delegated to and administered by Nominet UK. It allows registration of third-level domains only, under co.uk, gov.uk, org.uk, etc.
|
Posted by Killer Tofu, 01-13-2010, 03:24 PM |
You can check the number of .'s in the string (referring URL or submitted url) -- that can help you decide, right?
Aka if you say give us the direct URL to your site, it should be like
google.com
that's 1 period
if they give you
apps.google.com
that's 2 periods
|
Posted by tech163, 01-13-2010, 07:44 PM |
Try this script:
|
Posted by Negizmo, 01-13-2010, 09:11 PM |
Think.
google.co.uk
That's two dots, but it's certainly not a subdomain - that logic is majorly flawed.
You may be better off just manually banning.
|
Posted by GregVernon, 01-14-2010, 03:35 AM |
My thoughts exactly.
|
Add to Favourites Print this Article
Also Read