Customised HTML pages for Your HTTP Server


If a HTTP request is not found on a server, the browser normally will redirect to a 404 error page. In fact, you can customise the error pages on different HTTP codes e.g. 404, 403 etc.

All you have to do is to create a .htaccess file (if your server is hosted on Linux + Apache) and put it on the root directory of your FTP. In my case, I am hosting my domain at fasthosts, therefore I put the .htaccess file one directory level up htdocs/

At first, I did not have write permissions on .htaccess file, which was created by the system in the first place. I also do not have sudo right. Therefore, I renamed the .htaccess file and created a new one by myself, which bypasses the security issue.

The .htaccess file is also used to rewrite the URL according to the rules defined. For example, after you install wordpress, you will normally find a .htaccess file created by wordpress which redirects user-friendly URLs.

To customise the pages, you can add the following to the .htaccess file. The .htaccess will be interpreted by the Apache server one level by one level down if you place .htaccess file at different directories. The sub-directory will overwrite the settings of .htaccess from the parent directories.

ErrorDocument 404 /html/page404.html
ErrorDocument 400 /html/upgrade.html
ErrorDocument 401 /html/page404.html
ErrorDocument 403 /html/page404.html
ErrorDocument 500 /html/upgrade.html

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
282 words
Last Post: Mono-Develop from Linux
Next Post: Codeforces: B. Limit

The Permanent URL is: Customised HTML pages for Your HTTP Server

Leave a Reply