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:
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:
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 site behavior.