Custom Error Pages Apache Ubuntu
Contents |
In submit Tutorials Questions Projects Meetups Main Site logo-horizontal DigitalOcean Community Menu Tutorials Questions Projects Meetups Main Site Sign Up Log In submit apache custom 404 error page View All Results By: Justin Ellingwood Subscribe Subscribed Share Contents Contents We apache custom error log virtualhost hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure
Apache Set 404 Page
for developers. Learn more → 6 How To Configure Apache to Use Custom Error Pages on Ubuntu 14.04 Posted Jun 9, 2015 45.6k views Apache Ubuntu Introduction Apache is the
Php Custom Error Page
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 how to configure Apache to use custom error pages on tomcat custom error page 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/custom_404.html - echo "
I have no idea where that file is, sorry. Are you sure you typed in the
404 page not found error page Written by Guillermo Garron Date: 2013-01-11 15:47:35 00:00 Two years ago I have posted
Apache Default Error Page
about how to set custom 404 "Page not found" error in Nginx. apache 404 redirect I am working more with Apache than with Nginx these days. After learning about Apache MPM Worker I started apache 404 error with Apache again. Well today I will show you different ways to configure 404 custom pages with Apache2. For my tests I have used Ubuntu 12.10, but it should work the https://www.digitalocean.com/community/tutorials/how-to-configure-apache-to-use-custom-error-pages-on-ubuntu-14-04 same on any other distribution. Custom 404 "Page Not Found" with Apache2 There are different options. .htaccess file When you do not have access to the Apache configuration file, which is the case with mosts shared web hosting providers. But they most of the time gives you access to the htaccess file where you can configure your custom error page or message. https://www.garron.me/en/linux/custom-404-page-not-found-error-apache2-ubuntu-linux.html With a text editor create an error page, you can name it anything you want, what about 404.html Inside you can enter something like this:
Page not found Page not found
Sorry but the page you are looking for is not here, please got to our Home page
Now add to your htaccess file, this line: ErrorDocument 404 /404.html Be sure to have 404.html on the root folder of your server. Virtual host individual file If you are working with Ubuntu, you will find two important folders under Apache configuration which are: /etc/apache2/sites-available /etc/apache2/sites-enabled The latter are symlinks to the former, so you can go to that folder and pick each of files there (each one is one virtual server) and add this line before the tag. ErrorDocument 404 /404.html Global configuration You can also configure one path for all Virtual servers. In that case add the line. ErrorDocument 404 /404.html To the file /etc/apache2/conf.d/localized-error-pages, you can run this command: sudo sh -c 'echo "ErrorDocument 404 /404.html" >> etc/apache2/conf.d/localized-errorgeneric error responses in the event of 4xx or 5xx HTTP status codes, these responses are rather stark, uninformative, and can be https://httpd.apache.org/docs/2.4/custom-error.html intimidating to site users. You may wish to provide custom error responses which are either friendlier, or in some language other than English, or perhaps which are styled more in line with http://serverfault.com/questions/591866/where-to-find-the-default-status-codes-file-for-apache-in-ubuntu-12-04 your site layout. Customized error responses can be defined for any HTTP status code designated as an error condition - that is, any 4xx or 5xx status. Additionally, a set of values error page are provided, so that the error document can be customized further based on the values of these variables, using Server Side Includes. Or, you can have error conditions handled by a cgi program, or other dynamic handler (PHP, mod_perl, etc) which makes use of these variables. Configuration Available Variables Customizing Error Responses Multi Language Custom Error Documents See alsoComments Configuration Custom error documents are configured custom error page using the ErrorDocument directive, which may be used in global, virtualhost, or directory context. It may be used in .htaccess files if AllowOverride is set to FileInfo. ErrorDocument 500 "Sorry, our script crashed. Oh dear" ErrorDocument 500 /cgi-bin/crash-recover ErrorDocument 500 http://error.example.com/server_error.html ErrorDocument 404 /errors/not_found.html ErrorDocument 401 /subscription/how_to_subscribe.html The syntax of the ErrorDocument directive is: ErrorDocument <3-digit-code>
where the action will be treated as: A local URL to redirect to (if the action begins with a "/"). An external URL to redirect to (if the action is a valid URL). Text to be displayed (if none of the above). The text must be wrapped in quotes (") if it consists of more than one word. When redirecting to a local URL, additional environment variables are set so that the response can be further customized. They are not sent to external URLs. Available Variables Redirecting to another URL can be useful, but only if some information can be passed which can then be used to explain or log the error condition more clearly. To achieve this, when the error redirect is sent, additional environment variables will be set, which will Start 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 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 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 Where to find the default status codes file for Apache in Ubuntu 12.04 up vote 0 down vote favorite I am trying to customize all the status codes (error codes) in Apache - Ubuntu 12.04 LTS. The error message content I get on the browser for the error code 414 is: Request-URI Too Large The requested URL's length exceeds the capacity limit for this server. I went through the file: /etc/apache2/conf.d/localized-error-pages to see the default file which shows this error, I found the below line: ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var When I go through the file /usr/share/apache2/error/HTTP_REQUEST_URI_TOO_LARGE.html.var I didn't find the same message viewed on the browser! How come? Where I can find the default message to edit it? I edited the above file and nothing changed on the browser! One more thing, how can I customize this error to fit two different websites on the server (each website has different custom_error_414 page) UPDATE: I removed the comments on the file localized-error-pages but the output didn't change, when I add any path in the file localized-error-pages like: ErrorDocument 414 /var/www/myproject/error.php it doesn't work, but when I add a normal string like: ErrorDocument 414 "Long Request" it does work! Please provide some codes and details on how to fix this issue and how to customize the 414 error for two websites. UPDATE Below is the output of wget -O- -S ... --2014-05-02 21:02:26-- http://localhost/error//HTTP_PRECONDITION_FAILED.html.var Resolving localhost (localhost)... ::1, 127.0.0.1 Connecting to localhost (localhost)|::1|:80... failed: Connection refused. Connecting to localhost (localhost)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 403 Forbidden Date: Fri, 02 May 2014 21:02:26 GMT Server: Apache Vary: Accept-Encoding Content-Length: 1 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=iso-8859-1