I have an apache2 installation on www.main_domain.com (invalid underscore in domain name is intentional; this is an example), and the default page gives links for two secondary sites, also served by the same webserver since they point to the same address. The sites have lots of stuff in common, so I wouldn't want to do things using symbolic/hard links.

What I would like to do is:

  • if the client requests www.main_domain.com, I'd like to serve the current /var/www/index.html start page. That page contains links to secsite1.html and secsite2.html (the start pages for the secondary sites).
  • if the client requests www.secondary_site_1.com, I'd like to serve the /var/www/secsite1.html start page.
  • likewise for www.secondary_site_2.com: serve /var/www/secsite2.html as a first page.

Note that I want to change only the start page; otherwise, any page/image/file should be interchangeably accessible using the same path under each domain name.

Please let me know if I need to clarify more.

  • You're gonna suffer a lot of duplicate content penalty if you create 3 identical sites that only differ in their homepages. Also, your use of "subdomain" is confusing. That's not what most people mean when they refer to a subdomain. You should just refer to them as "subsites" or "secondary domains". – Lèse majesté Dec 28 '11 at 8:53
  • @Lèsemajesté: you're right about the term “subdomain” being confusing. Thanks. – tzot Dec 28 '11 at 9:20

I can't think of any reason why one would want this sort of setup, but to make the best of a bad situation, I would give the sites different docroots to avoid unnecessary duplication of content/URLs and make the sites more maintainable, e.g.:


To share assets, you ought to just keep the assets in the main site's docroot and use mod_rewrite to 301 redirect from the other domains. This will allow you to use a single folder to keep shared assets, prevent duplicate URLs, and allow visitors to share cached files between sites.

In case you want to give a specific site its own version of a particular file, you just need to upload it to the respective path in its docroot, and visitors to that domain will see that version while still sharing all other assets.

| improve this answer | |

You could use a scripting language to detect the url that was entered and have the index page (index.php for example) load index.html, subdomain1.html or subdomain2.html based on the sub-domain detected. For Example index.php would be:

if($_SERVER['HTTP_HOST'] == 'www.sub_domain_1.com') { include('subdomain1.html'); }
else if($_SERVER['HTTP_HOST'] == 'www.sub_domain_2.com') { include('subdomain2.html'); }
else { include('index.html'); }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.