Knowledgebase

How To Create Custom Error Pages for Parked Domains

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

Step 1: 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

Step 2: Create a file named as 404.php with the code like this:

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

Step 3: Add the directive like below into the public_html/.htaccess file:
ErrorDocument 404 /404.php

  • 527 Users Found This Useful
Was this answer helpful?