2

I'm planning to create my own domain parking solution. I'll have some folders on my /var/www with static websites and i'll park some domains (200 or more) to some folders. Some domains will be parked on a certain folder, other on other folders. Something like:

200 domains will be directed to /var/www/example 300 domains will be directed to /var/www/example2

How can i control this in an automated way? I'm thinking about creating an PHP script to do the job for me, but how would this work on the Apache side?

2 Answers 2

2

The eaiest way to do that would be to have two IP addresses, and just bind to the IP address, regardless of the hostname used. So any site that hits the IP address, regardless of the domain name, loads the same site.

This is the only viable way of doing it. You really don't want to have to maintain a virtualhost for 200 domains, scripting it.

Quick morality note: Domain Parking and Domain Squatting are very, very closely related, and the latter is illegal in some TLDs and juristictions, and dispised in all. You can also get in trouble if you're infringing on trademarks (which includes common typos of domain names), so I really, really hope you're doing parking of your own or your clients legitimate domain names

2
  • I wanted to put the same nameserver on all domain names.
    – MaidMaid
    Aug 20, 2011 at 21:48
  • @Maid - yes. That would in fact be a requirement for this to work. Aug 20, 2011 at 22:34
1

I can think in a PHP solution, something like:

<?
 // get the domain requested
$requested_domain = $_SERVER["SERVER_NAME"];

// you can also create a database with fields **domain** and **parktype** instead of an array
$park_one = array("domain1.com", "domain2.com");
$park_two = array("domain3.com", "domain4.com");

SWITCH(TRUE)
{
     // check if the domain exists in array $park_one
    case in_array($requested_domain, $park_one):
    header("Location: http://www.example1.com");
    break;

    // check if the domain exists in array $park_two
    case in_array($requested_domain, $park_two):
    header("Location: http://www.example2.com");
    break;

    default:
    //if none of the above applies, redirect to a third domain
    header("Location: http://www.example3.com");

}  
?>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .