Skip to main content

Setting a Custom 404 Error Page in .htaccess

We have to handle error page request by .htaccess like if someone requesting for 404,500 type of request/errors.

These are some of the most common errors:

401 – Authorization Required
400 – Bad request
403 – Forbidden
500 – Internal Server Error
404 – Wrong page

To handle these request/errors follow below code.

# Error pages handling
errorDocument 401 http://www.youwebsite.com/error_401.html
errorDocument 400 http://www.youwebsite.com/error_400.html
errorDocument 403 http://www.youwebsite.com/error_403.html
errorDocument 500 http://www.youwebsite.com/error_500.html
errorDocument 404 http://www.youwebsite.com/error_404.html


Each time if someone request for wrong page(404) he will be automatically redirected to error_404.html page, You can customize these pages as per you need.

If you want to disable whole directory then put below code in your .htaccess file

# Disable directory browsing, Nobody directly browse your directory.
Options All -Indexes

Comments