Knowledgebase

Back to My Domains

How To Custom Error Pages For Parked Domains


This article contains information about setting up custom error pages for my parked domains.


Parked Domains are pointed to the same folder as your main domain, so we have to use a script to distinguish requests to various domains.
This solution would use both .htaccess and a PHP-script.

1) At the first step, create various error pages for your domains and upload them into the public_html folder:
public_html/error404-domain1.html
public_html/error404-domain2.html
public_html/error404-main.html

2) At the second step, create a file named as 404.php with the code like this:

<?php
 $domain = strtolower(getenv("HTTP_HOST"));
 if(preg_match("/^(?:www\.)?(.+)$/i",$domain,$matches)) {
  $domain = $matches[1];
 }
 switch ($domain) {
  case "domain1.com":
   include("error404-domain1.html");
   break;
  case "domain2.com":
   include("error404-domain2.html");
   break;
  default:
   include("error404-main.html");
   break;
 }
 exit;
?>

This script would detect the domain and show the appropriate error page.

3) And finally, add the directive like below into the public_html/.htaccess file:

ErrorDocument 404 /404.php

Related Articles

What Is A Domain Name?
How To Register A Domain
How To Add Addon Domains In CHI
What Is An Anonymous Domain
What Can I Do With An Addon Domain?

Can’t Find what you need?

No worries, Our experts are here to help.