Create custom error pages through .htaccess file

This is always a best practices to create your own error page rather showing the host default page. You can use your own custom error pages for any know error like 404 - page not found, 500 - Internal Server Error etc.
It can be simply done by adding the following code to your .htaccess file.
ErrorDocument errornumber /file.html

1. 404 - page not found

RewriteEngine On
ErrorDocument 404 /404.html

2. 500 - Internal Server Error

RewriteEngine On
ErrorDocument 500 /500.html

3. 403 - Forbidden

RewriteEngine On
ErrorDocument 403 /403.html

4. 400 - Bad request

RewriteEngine On
ErrorDocument 400 /400.html

5. 401 - Authorization Required

RewriteEngine On
ErrorDocument 401 /401.html

You can also redirect all error to single page. like
RewriteEngine On
ErrorDocument 404 /404.html
ErrorDocument 500 /404.html
ErrorDocument 403 /404.html
ErrorDocument 400 /404.html
ErrorDocument 401 /401.html


Comments
comments powered by Disqus