GoWebsite.com provides Domain Registration
Website Hosting, On-Line Shopping Carts, SEO
Blog Hosting, Email Accounts, Security Certificates,
Merchant Accounts & other Website Products.
Free setup! Speak with us anytime: 480-624-2500

Setting a 404 Page on Subdomains and Aliased Domains

This article relates solely to Linux hosting plans.

404 Errors on subdomains

For each subdomain that points to a different folder, you need to put a new .htaccess file with executable permissions in that folder that looks like this:

ErrorDocument 404 /notfound.html

Make sure to change "notfound.html" to point to the file you would like displayed upon a 404 error. Your hosting account will know that "/notfound.html" translates to a path that is relative to the your subdomain's root directory. For instance, if you uploaded your .htaccess file and notfound.html to your "blog.coolexample.com" subdomain, in your FTP client, you'll notice that you're the "/blog/" directory. However, if a user encounters a 404 error on blog.coolexample.net your hosting account will know that it's already in "/blog/" because that's the root directory of your subdomain, and it will display the contents "/blog/notfound.html".

404 Errors on non-primary domains

Non-primary domains that point to your hosting account's root do not require any special configuration. Using the Hosting Control Panel to set the 404 error page will control all of the error pages for domains that point to your root domain folder. Your root domain folder is the path "/". For example, if you set your 404 errors to point to "/notfound.html" then if the user encounters an error on coolexample.com, they will see coolexample.com/notfound.html. If the user encounters an error on coolexample.org, coolexample.net, or coolexample.us, they will still see the contents "/notfound.html".

If you want to use change some aspect of the page dynamically to match the domain, you can use a php file, and access $_SERVER['SERVER_NAME']. That will return the Fully Qualified Domain Name (FQDN) of the current request as determined by your hosting account. For example, if you used this .htaccess file:

ErrorDocument 404 /notfound.php
And notfound.php looks like this:
The file you're looking for on <?php echo $_SERVER['SERVER_NAME']; ?> cannot be found.

If the user encounters a 404 error on coolexample.com, they will see "The file ... on coolexample.com ..." If the user encounters a 404 error on coolexample.net they will see "The file ... on coolexample.net ..."

NOTE: Use the Hosting Control Panel to manage your 404 error pages on your root domain, or any non-primary domains that point to your root domain folder. Uploading a custom .htaccess file to your root domain folder can cause potential conflicts and unexpected Website behavior.

Domain Registration
Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. Everything you need to get online - FREE with your domain.
Website Builder
For as little as $3.89 per month you can build your Website online with Website Builder using our easy to use professional templates.
Play Video - Demo
Quick Shopping Cart
Build and run your own successful online store in minutes. You're just five easy steps away!
Shopping Cart works with Google® and eBay®
Play Video
Website Hosting
Everything needed to give your website the high-performance home it deserves.  Protect transactions and secure your customer's data with
a SSL Certificate