Mobile app version of vmapp.org
Login or Join
Berryessa370

: How do I select a different start/default page per domain? I have an apache2 installation on www.main_domain.com (invalid underscore in domain name is intentional; this is an example), and the

@Berryessa370

Posted in: #Apache2 #Configuration

I have an apache2 installation on 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 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 secondary_site_1.com, I'd like to serve the /var/www/secsite1.html start page.
likewise for 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Berryessa370

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sims2060225

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.:

/var/www/site1
/var/www/site2
/var/www/site3


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.

10% popularity Vote Up Vote Down


 

@Hamaas447

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:

<?php
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'); }
?>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme