How to create custom Error Pages

Create a custom error page on 1and1 Linux Hosting

If you are hosting your site on 1and1's Linux servers, there are three ways you can use to create custom error pages.

By creating error files

The easiest way to create custom error pages is to create the page and give it one of the following names depending on the error page you are creating:

  • error403.html  (Forbidden You have requested to view a web page or directory to which you are not allowed.)
  • error404.html  (404 Not Found The web page you requested cannot be found on the web server.) This is the most common error page you will create.
  • error500.html  (Internal Error There’s something wrong on the web server and it cannot process your request or update.)

The files would then be uploaded to the directory where your particular domain resides. If you are hosting multiple sites on your server space, this is NOT the root directory.

EXAMPLE: My site genealogy-web-creations.com points to a folder genealogy-web-creations. I upload the error pages to the folder genealogy-web-creations.

If you have an external style sheet attached to your error page, you should link to the absolute url http://www.my-domain.com/my-stye-sheet.css. If you don't and your page may not display as expected for pages not located in your root directory.

You can test to see if your page works by typing in your url http://www.your-domain.com/any-file-that-does-not-exist.html

By creating a ".htaccess" file:

Step 1: Create the HTML page you want to use as your error message and upload it to your home directory (the directory where your domain resides.)

Step 2: Create a .htaccess file (using NotePad or a similar program) and add these lines which specify the substitution.

EXAMPLES

  • ErrorDocument 403 http://www.your-domain.com/403.html
  • ErrorDocument 404 http://www.your-domain.com/404.html
  • ErrorDocument 500 http://www.your-domain.com/500.html

Step 3: Upload the .htaccess file into your home directory (the directory where your domain resides. You will not see it once uploaded since it gets hidden by the server. When you are transferring the files, make sure you choose ascii as the transfer type. NOTE: If you already have an .htaccess file, just add the lines to the file that already exists. Using a .htaccess file does not work for PHP files.

Step 4: You can test to see if your page works by typing in your url http://www.your-domain.com/any-file-that-does-not-exist.html

By adding this piece of code in the .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocument.html

Create a file named "errordocument.html" containing your error message content. Upload the document to the directory where your domain resides.

NOTE: I have used the first two methods but not the last one.