Knowledgebase

KnowledgebaseCloud/VPSCloud HostingFile Management
Back to File Management

How To Create Custom Error Pages for Parked Domains


This article is for cPanel Accounts. Determine where your account is with this guide.

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



Related Articles

Am I Responsible For Monitoring My Bandwidth Usage
Can I Add My Own CGI Scripts
Can I Point My Primary Domain To A Sub-folder
Can I Reset My Website Files
Can I Use A .htpasswd File In My Account

Can’t Find what you need?

No worries, Our experts are here to help.