View Full Version : 2 domain names to one site

09-30-2005, 02:11 PM
I'm pretty certain this is a variation on a theme, and has been discussed here before, but I can't find the exact thread that I saw it in.

My question. I have 2 separate domains, and I want them to have separate index pages, but share all the other pages, images etc.

Currently I have this setup: www.domain1.com exists in /var/www/html/ and www.domain2.org is at /var/www/vhosts/domain2.

Is there a "better" way to set this up, and how do I do it? From reading it seems that my choices are between symlinks and .htaccess. I haven't used .htaccess yet, so if that's the way I need to go, I'm going to need some specific help.

Thanks for any help that comes my way!!

Cheers :),


09-30-2005, 03:17 PM
symlinks in your second domain should work fine I would think. If you don't mind the index page of the second domain leading to links on the main domain then all you should really have to symlink is the directory where the images are in the main site.

09-30-2005, 03:50 PM
If everything is going to be the same except for the index page. Why not just set domain2.org to point to your default root directory the same as domain1.com and then use a little php in your index page to serve up the index data as an include.

$thedomain = $_SERVER['HTTP_HOST'];

if ( $thedomain == 'domain1.com' || $thedomain == 'www.domain1.com' ) {
include ('index.domain1.inc.php');
} else {
include ('index.domain2.inc.php');

10-01-2005, 08:21 AM
Good suggestion bpk! I like the concept. Very simple and elegant.