How to specify your own ErrorDocuments using .htaccess file?
If you do not have custom files for handling error conditions and error codes like 404 ,500 and 401 etc ,the user experience would not be great. No one prefer to see the “404 Not Found” on their browser.The website developer should handle these scenarios.
You can do this by specifying the custom error document in your server web server configuration files.For Apache server you can do this by editing the .htaccess file.
Here given below are few of the common error codes and we can handle these
Client request Errors
400 – Bad request
401 – Authorization Required
403 – Forbidden
404 – Not Found
Server Errors
500 – Internal Server Error
501 – Not Implemented
502 – Bad Gateway
503 – Service Unavailable
504 – Gateway Timeout
505 – HTTP Version Not Supported
Here is the syntax to specify the error document.
1 2 3 4 | ErrorDocument errornumber /Customfile.html OR ErrorDocument code /directory/Customfile.extension |
if you use the second example above you can keep the custom error file in any directory and use the directory name to replace “directory”.
For example
1 2 3 4 5 6 | ErrorDocument 404 /MissingFile.html OR ErrorDocument 403 /errors/ForbiddenFile.html ErrorDocument 404 /errors/MissingFile.html ErrorDocument 500 /errors/ServerError.html |
Even though it is not advised you can specify a full URL rather than a virtual URL in the ErrorDocument string like http://abcd.com/errors/notfound.html rather than /errors/notfound.html.
Related articles
- 7 steps to Speed up website loading – Website Optimization Tips -Part 1
- Speed up website -Compress CSS/JavaScript using GZIP/DEFLATE compression – Optimization Tips -Part 2
- Check website/ web page for css/script Gzip/ Deflate compression – Optimization Tips -Part 3
Sign up or join Globinch on Social Media
Stay Connected
Follow globinch
Popular Posts
- Search Engines for File Sharing Sites : Rapidshare Search, Megaupload and More 6 comment(s) | 16258 view(s)
- Turn your Windows 7 Computer Into a Personal Wi-Fi Hotspot 15 comment(s) | 16117 view(s)
- Google Translate Now supports Bengali, Gujarati, Kannada, Tamil and Telugu 2 comment(s) | 15714 view(s)
- Google Top Searches Today – Hot Google Search Words today 12 comment(s) | 11559 view(s)
- Best PDF OCR Tools to Convert Scanned images to Text / Word Documents 20 comment(s) | 10154 view(s)
- Globinch Search 0 comment(s) | 8401 view(s)
- Access Blocked sites, Unblock Restricted Websites 15 comment(s) | 7310 view(s)
- Free Online OCR Software to Convert Images Into Searchable PDF, Doc, HTML or Text 3 comment(s) | 7238 view(s)
- Password Revealer – How To Reveal- Show Password Behind Asterisks? 7 comment(s) | 7180 view(s)
- Play Angry Birds Game Free and Offline in Chrome Browser 1 comment(s) | 7049 view(s)
Recent Articles
- Best Free Tools to Enlarge Images without Losing Quality
- How to Track Your Gmail Email and Schedule Gmail Mail Free?
- Google Webmaster Unnatural Links Detected Warning & Penalty
- How to Use Trial Software Version Forever Without Expire
- How to Use Folder as Drive or Convert Folder to Drive?
- Add Buttons, Message Boxes and Text Highlights in WordPress Post
- Top 20 Free WordPress Social Share Plugins
- rel=”shortlink” Short URL Indicator and Its WordPress Support
- Pagination SEO Using rel=”next” and rel=”prev” Link Attributes
- Watch Live IPL 2012 Season 5 Online on Your Computer or Mobile










Pingback: Website or Web page redirection using a .htaccess file | Globinch
Pingback: How to create and use .htaccess file? Common usage and risks | Globinch
Pingback: .htaccess Tutorial -A guide and .htaccess tricks and tips | Globinch