Serving content for parked domains

Tuesday, March 18th, 2008 anna-marie

I help out a non-profit and a few related parties by allowing them to share my hosting. I manage their webs for them anyway, so there is no need for them to access my control panel on ICDsoft. There are a couple of downsides of this simple approach, but nothing that is an issue for us. For example: email addresses work on any domain name. So fred@domain1 also works on fred@domain2. I have checked ICDsoft terms of service and policies and this seems to be acceptable use.

You could use this concept to serve up different content for localised versions of your websites. Eg: anmari.com.au could serve different content to anmari.com, maybe starting with G’day!

Park the new domain:

Specify the parking via the control panel and then inform the domain registrar of the name servers of the hosting account. The name servers usually look something like this:

  • ns1.s999.someserver.com
  • ns2.s999.someserver.com

Decide where to store files for additional domain (subfolder or subdomain):

On ICDSoft, if you want separate web statistics, then a sub domain can be used. Otherwise, to keep the related files clear of each other, each content is housed in a separate folder. Create the necessary folder or domain (via cp>filemanager or cp>subdomains) . The name of the subdomain does not have to be the same as the parked domain. You can choose a word that may help with search engine optimisation. For example for anmari.com I chose webdesign. So the actual URL that www.anmari.com redirects to is webdesign.anmari.com. For the non profit bythepeople.org.za we used volunteer.bythepeople.org.za.

Arrange php code to serve different content:

If you are using wordpress and perhaps other content management systems (Typo3 has the facility to server different content by domain name built-in) this is pretty straightforward.

Our common index.php file picks up the domain name being used and then includes an appropriate php file for the domain. This effectively redirects the http request. Once the user clicks through the navigation to other parts of your site, they will see the sub folder or sub domain name.

 <?php
if (strstr($_SERVER['SERVER_NAME'], "domain1.com")) {
 include('domain1.php');
}
elseif (strstr($_SERVER['SERVER_NAME'], "domain2.com")) {
 include('http://www.subdomain.domain2.com/index.php');
}
else {
 include('missing.html');
}
?>

Related posts:
  1. Multiple domains, 404’s, wordpress and php redirection ? For a while I had this mystery problem with one...
  2. Web Hosting Finding and choosing a good web host is a very...
  3. Prices Cost or consideration: Cost Indicator: Comment: Domain Names: from...
  4. About I am based in Sydney, Australia, but has developed websites...
  5. Typo3 Installation Following are the lognotes I made about the process of...