Custom Error Page Using .htaccess
Articles Code Recommended Most Popular .htaccess Error Documents for Beginners Apache allows you to customize the server at the directory level, using .htaccess files. This tutorial explains how to use them to serve custom 404 error (page not found), and other common error pages, to your users. In Apache, you can set up each directory on your server individually, giving them different properties or requirements for access. And while you can do this through normal Apache configuration, some hosts may wish to give users the ability to set up their own virtual server how they like. And so we have .htaccess files, a way to set Apache directives on a directory by directory basis without the need for direct server access, and without being able to affect other directories on the same server. One up-side of this (amongst many) is that with a few short lines in an .htaccess file, you can tell your server that, for example, when a user asks for a page that doesn't exist, they are shown a customized error page instead of the bog-standard error page they've seen a million times before. If you visit http://www.addedbytes.com/random_made_up_address then you'll see this in action - instead of your browser's default error page, you see an error page sent by my server to you, telling you that the page you asked for doesn't exist. This has a fair few uses. For example, my 404 (page not found) error page also sends me an email whenever somebody ends up there, telling me which page they were trying to find, and where they came from to find it - hopefully, this will help me to fix broken links without needing to trawl through mind-numbing error logs. [Aside: If you set up your custom error page to email you whenever a page isn't found, remember that "/favicon.ico" requests failing doesn't mean that a page is missing. Internet Explorer 5 assumes everyone has a "favicon" and so asks the server for it. It's best to filter error messages about missing "/favicon.ico" files from your error logging, if you plan to do any.] Setting up your htaccess file is a piece of cake. First things first, open notepad (or better yet, [url=http://www.editplus.com/]EditPlus2[/url]), and add the following to a new document: ErrorDocumen
It Yourself We Build It For You Mobile Website Web Hosting Web Hosting WordPress Blog Hosting SharePoint Hosting VPS Hosting Email Personal Email Business Email Mobile Email Microsoft Exchange Email Ecommerce Ecommerce Website JumpStart Store Set-up Ecommerce Care Ecommerce Web Design Call Center Plus Take-a-Payment SSL Certificates SSL Certificates Site Seal Website Scan and Protect Marketing Premium Services Ignite Online Marketing Facebook Boost Pay Per Click Marketing (PPC) ReputationAlert Google Places™ Search Engine Optimization (SEO) Email Marketing Email Marketing Done For You https://www.addedbytes.com/articles/for-beginners/error-documents-for-beginners/ Local Leads Design Website Design Ecommerce Website Design Web Enhancements Website Maintenance Options Premium Support Plans Custom Logo Design MyTime Premium Support Domain Names Search for a Domain Name Transfer to Network Solutions Website Forwarding Private Domain Registration Domain Expiration Protection Premium Domain Names Websites Do It Yourself We Build It For You Mobile Website eCommerce Ecommerce http://www.networksolutions.com/support/how-to-use-the-htaccess-file-to-display-custom-error-pages/ Website JumpStart Store Set-up Custom Ecommerce Design Take-a-Payment Hosting & SSL Web Hosting WordPress Blog Hosting SSL Certificates Site Seal Website Scan and Protect Professional Email Personal Email Business Email Mobile Email Microsoft Exchange Email Online Marketing Premium Services Ignite Online Marketing Facebook Boost Pay Per Click Marketing (PPC) Mobile Advertising ReputationAlert Search Engine Optimization (SEO) Local Leads Home » Hosting » Web Hosting » nsHosting Shared FAQs » Scripting » How To Use The .htaccess File To Display Custom Error Pages Search Support Let Us Make it Easy for You. Call 1-877-898-3290 for MyTime Support™. Learn More How To Use The .htaccess File To Display Custom Error Pages Rate this Article Article Rating: 2 / 5 Votes: 26 Custom error pages are frequently used to provide additional information to visitors and to maintain the look and feel of your Web site. Some of the more common customized error pages include: 206 Partial content 301 Document moved permanently 302 Document found elsewhere 400 Bad request 401 Authorization required 403 Access forbidde
- sql HTML & Graphics Tutorials getting started backgrounds buttons browser specific colors forms frames html 4.01 tags html 4.01 ref image maps tables web graphics Beyond HTML asp cascading style sheets css keyword ref cgi scripting developer research center dhtml/layers http://www.htmlgoodies.com/beyond/reference/article.php/3472591/How-Do-I-Create-a-Custom-404-Error-Page.htm dot net java applets javascript javascript frameworks javascript keyword ref javascript script tips mobile web https://paulund.co.uk/use-htaccess-to-redirect-custom-error-pages development open source cms php security SEO vb script keyword ref webmaster tips webmaster projects webmaster toolbox video xml general reference pieces the master list Need Help? discussion boards mentors Post a comment Email Article Print Article Share Articles Reddit Facebook Twitter del.icio.us Digg Slashdot DZone StumbleUpon FriendFeed Furl Newsvine Google LinkedIn MySpace Technorati YahooBuzz How Do I Create custom error a Custom 404 Error Page? By Joe Burns Tweet Ah, the aggravating 404 error page. You've seen it. There you are, surfing in your favorite search engine when you happen upon just the thing you're looking for. You click: (***Raspberry Sound Effect***) Nothing but a white page with the words "404 Error" and some other techie-sounding speak beneath. What's even more cheesy about the error code is that it really doesn't tell you what custom error page the problem is. Basically you've been informed that the server cannot find what you want. It doesn't tell you why, how to fix it, or where to go from that point. You really don't have much choice but to hit your BACK button, call the computer a dirty name, and try again. But then you see it--a server that's set up with its own special 404 error page that politely apologizes and offers you links to e-mail site administrators and maybe a site search engine. Now that's class! So I waltzed into the office of the Webmaster at work and asked how it was done. I was stunned at how easy it is to set up. Want one of your own? Here's how. You'd Best Ask First I'm going to offer you a very basic fix to this problem, but you'd best ask your system people if they want you doing this first. Better yet, ask them if you might mess things up by doing this. Your .htaccess File This is the file that will do the trick for you. You should already have one waiting inside of your Web site directory. If you don't, then you'll need to create it. FTP into your server so you're looking at the top level directory where you store your Web page files.
not look good on your site and don't look professional. The best solution to use if your server returns with an error is to display a custom error page with your own website skin. There are different ways you can make the server display your custom error pages. You can either use your server side language to search for HTTP error codes before displaying a page and redirect the visitor to a custom page for that error. An easier option is to use your htaccess file to redirect the visitor when it detects a server error code. Use the following htaccess snippet to redirect visitors to custom error pages. ErrorDocument 400 /400.html ErrorDocument 401 /401.html ErrorDocument 403 /403.html ErrorDocument 404 /404.html ErrorDocument 500 /500.html ErrorDocument 502 /502.html ErrorDocument 504 /504.html Display Error Pages With PHP If you don't want to create 7 different pages for your error codes and would like to use the same page but change the text depending on what the error code is then the best option is to use PHP to change the content. First we use htaccess to redirect all codes to the same page. ErrorDocument 400 /error-code.php ErrorDocument 401 /error-code.php ErrorDocument 403 /error-code.php ErrorDocument 404 /error-code.php ErrorDocument 500 /error-code.php ErrorDocument 502 /error-code.php ErrorDocument 504 /error-code.php Now you can just create one page error-code.php and add the following code to display different messages depending on the error code. Use the following code snippet to use a different title and description for the different error codes.