7

Not only easy ones like .com or .net, but also, .co.uk, .fr, .gov.rw ... ?

Should I really make a huge mapping "tld to relevant whois server", or is there an easier way ?

Jonas
  • 121,568
  • 97
  • 310
  • 388
BraveSirFoobar
  • 794
  • 1
  • 6
  • 12

5 Answers5

11

http://php.net/manual/en/function.checkdnsrr.php

if (checkdnsrr('test.nl', 'A')) // or use ANY or for other see above link
{
    echo 'Domain exists';
}
else
{
    echo 'Domain does not exist';
}
Mike
  • 1,883
  • 3
  • 23
  • 17
  • Hello mike when i add wrong url in this it even says domain exisit for example adfsfsdf.com it says domain exists.i tried many other php function but all having same problem – user2477139 Aug 01 '15 at 05:39
  • I guess "." is missing after domain name like test.com. if (checkdnsrr('test.nl.', 'ANY')) // or use ANY or for other see above link { echo 'Domain exists'; } else { echo 'Domain does not exist'; } – Bikash Ranjan Sep 08 '15 at 08:56
  • Two wrong advises: do not use the DNS to check if a domain name exists (because a domain name can be registered but not delegated) and do not use the ANY resource type as it does not do what you think it does (and if you were at the stage of using the DNS you should query the authoritative nameservers, not recursive ones, where ANY is used) – Patrick Mevzek Jan 04 '18 at 21:28
4

http://whois.net/ any good?

DanSingerman
  • 36,066
  • 13
  • 81
  • 92
4

PHP:

$URL = "http://www.dotnetindex.com/articles/5261-Article--AJAX-Tips-and-Tricks.asp";
$PARSED_URL = parse_url($URL);
$DOMAIN = $PARSED_URL['host'];
$ip = gethostbyname($DOMAIN);

if($ip===$DOMAIN)
{
    echo "Url does not exist";
}
else
{
    echo "Url exists";
}
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
  • 1
    Not a good check, for example example.org may not point to an IP but www.example.org may point to a valid IP (example.org may only have NS and MX records). –  Jan 24 '09 at 11:38
2

Do you want to know if the domain is registered, or if it's actually present in the DNS ?

If the former, then whois based approaches are the only viable way, and even then you'll run into massive issues parsing the highly varied output from the various TLDs whois servers.

If the latter, a simple DNS lookup will suffice.

Alnitak
  • 334,560
  • 70
  • 407
  • 495
0

You may have to try different services:

This one seems to work for a lot more than the standard Whois: http://whois.domaintools.com/

Works for .co.uk and .fr as well as the standard ones

Damien
  • 13,927
  • 14
  • 55
  • 88