Don't Afraid of Source Code

How to create custom error page using .htaccess

0

Different types of error you want to cover

  • 400 – Bad request
  • 401 – Authorization Required
  • 403 – Forbidden
  • 404 – Not Found
  • 500 – Internal Server Error

Now create a .htaccess file and put following code in your .htaccess file

RewriteEngine On
ErrorDocument 400 /badrequest.php
ErrorDocument 401 /authreqd.php
ErrorDocument 403 /forbidden.php
ErrorDocument 404 /pagenotfound.php
ErrorDocument 500 /internalerror.php

You can name error page whatever you want. In the above example all error pages located in the root folder.

.htaccess file must be in root folder.

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy