{"id":4511,"date":"2015-03-31T09:12:38","date_gmt":"2015-03-31T01:12:38","guid":{"rendered":"http:\/\/rmohan.com\/?p=4511"},"modified":"2015-03-31T09:12:55","modified_gmt":"2015-03-31T01:12:55","slug":"apache-custom-error-page","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4511","title":{"rendered":"Apache \u2013 Custom Error Page"},"content":{"rendered":"<p>Error handling is one of the important parts when running a server. The application running inside the server provides the necessary services to the client but it is the responsibility of the server to serve custom pages for errors. In this article we will see how we can configure custom error page 404 for Apache web server along with Tomcat.<\/p>\n<ol>\n<li>Create a 404 error page as<\/li>\n<\/ol>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt; Hello This a 404 Error page &lt;\/head&gt;<\/p>\n<p>&lt;body bgcolor=&#8221;green&#8221;&gt;<\/p>\n<p>&lt;\/h3&gt; this is green and 404 &lt;\/h3&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p>\n<p>Copy the file to \/var\/www\/webroot\/ROOT\/ location<\/p>\n<ol start=\"2\">\n<li>Once the file is created, configure Apache Configuration file as<\/li>\n<\/ol>\n<p>&lt;VirtualHost *:80&gt;<\/p>\n<p>ServerAdmin webmaster@dummy-host.example.com<\/p>\n<p>DocumentRoot \/var\/www\/webroot\/ROOT\/<\/p>\n<p><strong>\u00a0ErrorDocument 404 \/404.html<\/strong><\/p>\n<p>ServerName dummy-host.example.com<\/p>\n<p>ErrorLog logs\/dummy-host.example.com1-error_log<\/p>\n<p>CustomLog logs\/dummy-host.example.com1-access_log common<\/p>\n<p>ProxyRequests Off<\/p>\n<p>ProxyPreserveHost On<\/p>\n<p>&lt;Proxy *&gt;<\/p>\n<p>Order deny,allow<\/p>\n<p>Allow from all<\/p>\n<p>Options +Indexes<\/p>\n<p>&lt;\/Proxy&gt;<\/p>\n<p>ProxyPass \/application1 http:\/\/localhost:8080\/myApp\/<\/p>\n<p>ProxyPass \/application2 http:\/\/localhost:8080\/Sample-app\/test.html<\/p>\n<p>ProxyPassReverse \/application1\/ http:\/\/localhost:8080\/myApp\/<\/p>\n<p>ProxyPassReverse \/application2\/ http:\/\/localhost:8080\/Sample-app\/test.html<\/p>\n<p>&lt;\/VirtualHost&gt;<\/p>\n<p>All we need to do is add an ErrorDocument entry to our http.conf file. On the ErrorDocument line, we specify the error code, which in this case is a 404. After that, we can specify either a text message or the page to display and then file to be displayed ( 404.html ). Restart the Apache server.<\/p>\n<p>Now once we access a different path, we see the 404 error page as,<\/p>\n<p><strong><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/03\/apache.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4512\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/03\/apache.jpg\" alt=\"apache\" width=\"741\" height=\"112\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2015\/03\/apache.jpg 741w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/03\/apache-300x45.jpg 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/03\/apache-150x23.jpg 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/03\/apache-400x60.jpg 400w\" sizes=\"(max-width: 741px) 100vw, 741px\" \/><\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Error handling is one of the important parts when running a server. The application running inside the server provides the necessary services to the client but it is the responsibility of the server to serve custom pages for errors. In this article we will see how we can configure custom error page 404 for Apache [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4511"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4511"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4511\/revisions"}],"predecessor-version":[{"id":4514,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4511\/revisions\/4514"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}