Apache Custom Error Responses
Contents |
refer to the current version of httpd instead, documented at: Current release version of Apache HTTP Server documentationYou may follow this link to go to apache custom error log virtualhost the current version of this document.Custom Error Responses Available Languages: en | es
Apache Custom Error Page
| fr | ja | ko | tr Additional functionality allows webmasters to configure the response of Apache to apache custom 404 error page some error or problem. Customizable responses can be defined to be activated in the event of a server detected error or problem. If a script crashes and produces a "500 Server Error" apache error messages response, then this response can be replaced with either some friendlier text or by a redirection to another URL (local or external). Behavior Configuration Custom Error Responses and Redirects Behavior Old Behavior NCSA httpd 1.3 would return some boring old error/problem message which would often be meaningless to the user, and would provide no means of logging the symptoms which caused it. New Behavior The
Apache Error Handling
server can be asked to: Display some other text, instead of the NCSA hard coded messages, or redirect to a local URL, or redirect to an external URL. Redirecting to another URL can be useful, but only if some information can be passed which can then be used to explain and/or log the error/problem more clearly. To achieve this, Apache will define new CGI-like environment variables: REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg
REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712)
REDIRECT_PATH=.:/bin:/usr/local/bin:/etc
REDIRECT_QUERY_STRING=
REDIRECT_REMOTE_ADDR=121.345.78.123
REDIRECT_REMOTE_HOST=ooh.ahhh.com
REDIRECT_SERVER_NAME=crash.bang.edu
REDIRECT_SERVER_PORT=80
REDIRECT_SERVER_SOFTWARE=Apache/0.8.15
REDIRECT_URL=/cgi-bin/buggy.pl Note the REDIRECT_ prefix. At least REDIRECT_URL and REDIRECT_QUERY_STRING will be passed to the new URL (assuming it's a cgi-script or a cgi-include). The other variables will exist only if they existed prior to the error/problem. None of these will be set if your ErrorDocument is an external redirect (anything starting with a scheme name like http:, even if it refers to the same host as the server). Configuration Use of ErrorDocument is enabled for .htaccess files when the AllowOverride is set accordingly. Here are some examples... ErrorDocument 500 /cgi-bin/crash-recover
ErrorDocument 500 "Sorry, our script
In submit Tutorials Questions Projects Meetups Main Site logo-horizontal DigitalOcean Community Menu Tutorials Questions Projects Meetups Main Site Sign Up apache set 404 page Log In submit View All Results By: Justin Ellingwood Subscribe Subscribed php custom error page Share Contents Contents We hope you find this tutorial helpful. In addition to guides like this one,
Tomcat Custom Error Page
we provide simple cloud infrastructure for developers. Learn more → 6 How To Configure Apache to Use Custom Error Pages on Ubuntu 14.04 Posted Jun 9, 2015 44.7k views http://httpd.apache.org/docs/2.0/custom-error.html Apache Ubuntu Introduction Apache is the most popular web server in the world. It is well-supported, feature-rich, and flexible. When designing your web pages, it is often helpful to customize every piece of content that your users will see. This includes error pages for when they request content that is not available. In this guide, we'll demonstrate https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-on-ubuntu-14-04 how to configure Apache to use custom error pages on Ubuntu 14.04. Prerequisites To get started on with this guide, you will need a non-root user with sudo privileges. You can set up a user of this type by following along with our initial set up guide for Ubuntu 14.04. You will also need to have Apache installed on your system. Learn how to set this up by following the first step of this guide. Creating Your Custom Error Pages We will create a few custom error pages for demonstration purposes, but your custom pages will obviously be different. We will put our custom error pages in the /var/www/html directory where Ubuntu's Apache installation sets its default document root. We'll make a page for 404 errors called custom_404.html and one for general 500-level errors called custom_50x.html. You can use the following lines if you are just testing. Otherwise, put your own content in these locations:
- echo "
Error 404: Not found :-(
" | sudo tee /var/www/html/customStart here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business http://serverfault.com/questions/362234/apache-default-error-page Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only https://www.xav.com/scripts/guardian/help/1001.html takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Apache default error page up vote 0 down vote favorite custom error I have a development server and I would like to configure Apache so that when a 500 http code is generated it will display the error directly in the response (i.e. what would be printed to /var/log/httpd/error_log is displayed to the user). However, I cannot figure out where this directive is. Any help? apache-2.2 configuration share|improve this question edited Feb 21 '12 at 14:59 Kyle Smith 7,6651730 asked Feb 21 '12 at 14:35 Thomas 112212 add apache custom error a comment| 2 Answers 2 active oldest votes up vote 2 down vote Set up Apache to use server-side includes (.shtml files) and configure a custom error page as above (though naturally pointing to an .shtml file), and in that custom error page use something like this:
The requested page,
Click here to return from whence you came.
--> share|improve this answer answered Jul 14 '12 at 16:47 Lee Gee 18314 add a comment| up vote 2 down vote I believe the directive you are looking for is ErrorDocument (documented here). For example:... ErrorDocument 500 /error/500.html On a second read-through of your question it appears you may be asking for Apache to display the error directly in the browser (i.e. what would appear in /var/log/httpd/error_log). Can you clarify? share|improve this answer edited Sep 22 at 5:19 Community♦ 1 answered Feb 21 '12 at 14:38 Kyle Smith 7,6651730 Hi. Your second guess is the one I am interested in. I want it to print the error to the browser, not a custom error page. Thanks –Thomas Feb 21 '12 at 14:44 3 This isn't seemingly easy as it represents a complex changSystem > Help > 1001 How to enable custom error messages on the Apache web server This document describes how to configure the Apache web server so that it will redirect common server errors - like 404 Not Found or 500 Internal Server Error - to a Perl CGI script for processing. In order to configure Apache error handling, you must: Edit a ".htaccess" file in the root folder of your web site Have the "AllowOverride" privilege granted by the system administrator who set up Apache. (This is automatically the case for the majority of Apache users.) If you do not have the AllowOverride privilege, then you will have to ask your administrator to take these steps on your behalf. Follow these steps to add a custom error page to Apache: Before you tweak Apache, first make an initial request to your custom error page using its direct URL. Make sure it displays properly. If your error page is a Perl CGI script, and it is failing, then it will be very difficult to debug what is going on when other errors are redirected to it. Some FTP servers and FTP client software do not allow the viewing or manipulation of files that begin with a dot, like ".htaccess". Some systems will allow you to upload files named ".htaccess", but once the file is on the server, the file won't appear in your file list and you won't be able to delete or rename it - which will be a problem if the .htaccess file makes your site inaccessible. So, first, create an empty file named ".foo". Upload it to your site. Will your FTP client software allow it? Will the FTP server accept it? Can you then rename and delete the file? If you have trouble with any of these operations, then you should not proceed to .htaccess. Instead contact your system administrator to see about getting the right software/settings for the job. Before beginning, request a file from your website that doesn't exist, like www.foo.com/no_such_file. Observe the 404 Not Found error handling: do you see a plaintext file like "404 Not Found"? Or do you see a pretty error message that so