Custom Error Pages
Instead of your visitors receiving the ugly default error messages, you can create a custom error page to be shown instead.
You can create one page for all errors:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /errorpage.html [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /errorpage.html [L]
In the above example, the page “errorpage.html” will be shown to anyone trying to view a nonexistant page or who would otherwise receive an error message.
You can also create a custom error page for each type of error:
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/500.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/500.html
This htaccess function is particularly useful for 404 errors. Instead of just displaying a dead-end “page not found”, you can create a nicer looking page which shows suggestions for what the visitor may have been looking for or even include the option for the visitor to search for another page on your site.




