Easy htaccess error pages
You can use htaccess error pages to friendly inform visitors that were lost on your website. They replace the typical "404 Page Not Found", so instead of leaving them alone, you can funnel your visitors back to your website.ErrorDocument code /directory/error-page.htmlNow you create the error-page.html and put it in the directory you specified in the htaccess file. If it resides in the root of your website, no directory specification is necessary.
There are a few server errors that can occur if a browser asks for a page. They are identified by a code and the most common ones are:
- 400 - bad file request; this usually indicates, that the syntax used in the URL is not correct,
- 401 - unauthorized; the server expects some form of authentication and is not getting it or it failed,
- 402 - payment required, but hasn't been implemented yet,
- 403 - forbidden; for whatever reason a special permission is needed to access the site and
- 404 - not found; the requested page could not be found on the server
You can write a seperate page for each error code. Just add the code to your htaccess file like this:
ErrorDocument 400 400badrequest.htmlOf course you can name the pages to your likings. These are just examples of htaccess error pages.
ErrorDocument 401 401authentication.html
ErrorDocument 403 403forbidden.html
ErrorDocument 404 404notfound.html
And that's it. htaccess error pages are a very easy way to inform lost visitors about the status of their request and guide them further through your site.
Click to return to htaccess possibilities