Customize Error Pages Htaccess
Contents |
be getting into progressively more advanced stuff after this. Successful Client Requests 200 OK 201 Created 202 Accepted 203 Non-Authorative Information 204 No Content 205 Reset Content 206 Partial Content Client Request Redirected 300 Multiple Choices 301 Moved apache custom error pages Permanently 302 Moved Temporarily 303 See Other 304 Not Modified 305 Use Proxy Client Request
Apache Custom 404 Error Page
Errors 400 Bad Request 401 Authorization Required 402 Payment Required (not used yet) 403 Forbidden 404 Not Found 405 Method Not Allowed 406
Php Custom Error Page
Not Acceptable (encoding) 407 Proxy Authentication Required 408 Request Timed Out 409 Conflicting Request 410 Gone 411 Content Length Required 412 Precondition Failed 413 Request Entity Too Long 414 Request URI Too Long 415 Unsupported Media
Tomcat Custom Error Page
Type Server Errors 500 Internal Server Error 501 Not Implemented 502 Bad Gateway 503 Service Unavailable 504 Gateway Timeout 505 HTTP Version Not Supported In order to specify your own ErrorDocuments, you need to be slightly familiar with the server returned error codes. (List to the right). You do not need to specify error pages for all of these, in fact you shouldn't. An ErrorDocument for code 200 would cause an infinite errordocument 404 htaccess loop, whenever a page was found...this would not be good. You will probably want to create an error document for codes 404 and 500, at the least 404 since this would give you a chance to handle requests for pages not found. 500 would help you out with internal server errors in any scripts you have running. You may also want to consider ErrorDocuments for 401 - Authorization Required (as in when somebody tries to enter a protected area of your site without the proper credentials), 403 - Forbidden (as in when a file with permissions not allowing it to be accessed by the user is requested) and 400 - Bad Request, which is one of those generic kind of errors that people get to by doing some weird stuff with your URL or scripts. In order to specify your own customized error documents, you simply need to add the following command, on one line, within your htaccess file: ErrorDocument code /directory/filename.ext or ErrorDocument 404 /errors/notfound.html This would cause any error code resulting in 404 to be forward to yoursite.com/errors/notfound.html Likewise with: ErrorDocument 500 /errors/internalerror.html You can name the pages anything you want (I'd recommend something that would prevent you from forgetting what the page is being used for), and you can place the error pages anywhere you want within your site, so long as the
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 htaccess errordocument 404 not working explains how to use them to serve custom 404 error (page not 404 htaccess redirect found), and other common error pages, to your users. In Apache, you can set up each directory on htaccess errordocument not working 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 http://www.javascriptkit.com/howto/htaccess2.shtml 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 https://www.addedbytes.com/articles/for-beginners/error-documents-for-beginners/ 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 Exp
code: FALL2016 « WordPress Tip: Careful with that Autosave, Eugene CSS/(X)HTML Tutorial: Hovering Accessibility Jump... » Custom HTTP Errors via htaccess We all know how important it is to deliver sensible, https://perishablepress.com/custom-http-errors-via-htaccess/ helpful 404 error pages to our visitors. There are many ways of achieving this functionality, including the well-known htaccess trick used to locally redirect users to custom error pages: # htaccess custom error pages ErrorDocument 400 /errors/400.html ErrorDocument 401 /errors/401.html ErrorDocument 403 /errors/403.html ErrorDocument 404 /errors/404.html ErrorDocument 500 /errors/500.html ..and so on. These directives basically tell Apache to deliver the designated documents for their associated error types. error page Many webmasters and developers employ this trick to ensure that visitors receive customized error pages that are generally more user-friendly or design-specific than the rather unfriendly Apache defaults. Serving custom error pages is an excellent way to enhance overall site usability and accessibility, but there are several other useful techniques to consider as well. Change the default error message You don’t need to design a complete custom error page set of customized error documents just to get your point across. Simply changing the default error message to something more useful is a great way to spice things up with minimal fuss: # htaccess custom error messages ErrorDocument 400 "Ooops - Bad request! ErrorDocument 401 "Speak friend and enter ErrorDocument 403 "Strictly fabidden.. ErrorDocument 404 "Missing in action.. ErrorDocument 500 "Server gone wild.. ..or whatever. You can change the custom message to anything you want, but it must be plain text. This technique is ideal for hardcore sites with an audience that is a bit more “error-savvy” than the typical visitor. Note that the initial quotation mark (") specifies the character string as text and is not included in the message itself. No closing quotation mark is required. Redirect to a script Moving in the other direction, you may wish to incorporate some dynamic functionality into your error messages. For example, if you had a script that customized the error message by employing, say, referrer, client, and query data, you could redirect your error pages like so: # htaccess custom error scripts ErrorDocument 400 /errors/redirection.php ErrorDocument 401 /errors/authentication.php ErrorDocument 403 /errors/explanation.php ErrorDocument 404 /cgi-bin/not_found.pl ErrorDocument 500 /cgi-bin/server_error.pl