How To Find The Best Domain Name
Wednesday, June 3rd, 2009One of the most frustrating steps I face when building a new website is looking for a great domain name. Since nearly every domain name you can think of is already taken, some creativity is needed here.
So here it is: I wrote a really super cool simple php script that searches for a free domain name that uses your keyword research file as an input.
This script get as input a csv files with your keywords, and checks for every keyword whether the the domain name built from these keywords with or without hyphens is free. The result of the script is your original csv file with 2 more columns containing the domain names found.
<?php
define(’KEYWORDS_FILE’,'keywords.csv’);
$f = @fopen(KEYWORDS_FILE, “r”);
while ($f && !feof($f))
{
$line = trim( fgets($f, 4096));
echo $line .”,” ;
// find the first string in the line, that comes before the first comma
if (preg_match(”/^([a-zA-Z0-9 ]+)/”, $line, $matches))
{
$keyword=$matches[1];
// check if the domain name is available
$domainName = str_replace(” “,”",$keyword) .”.com”;
$ip=gethostbyname($domainName);
if ($ip != $domainName)
{
echo “–,”;
}
else
{
echo $domainName .”,”;
}
// check if the domain name is available with hyphens
$hyphensDomainName = str_replace(” “,”-”,$keyword) .”.com”;
$ip=gethostbyname($hyphensDomainName);
if ($ip != $hyphensDomainName)
{
echo “–,”;
}
else
{
echo $hyphensDomainName .”,”;
}
}
echo “\n”;
}
fclose($f);
?>
I warmly recommend using this script, so that next time you buy a new domain name you can get your-keywords.comright away.
Notice that the script is based on gethostbyid() which checks if the domain exists and not if it is registered, so it is not 100% right.










