{"id":183,"date":"2009-02-13T11:12:07","date_gmt":"2009-02-13T16:12:07","guid":{"rendered":"http:\/\/www.webadminblog.com\/?p=183"},"modified":"2009-07-07T12:26:30","modified_gmt":"2009-07-07T17:26:30","slug":"customizing-apache-error-codes-by-url","status":"publish","type":"post","link":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/","title":{"rendered":"Customizing Apache Error Codes By URL"},"content":{"rendered":"<p>I&#8217;ve had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it.\u00a0 What I&#8217;ve come up with is somewhat interesting so I thought I&#8217;d share it with everyone.\u00a0 First, it is not technically possible to tell Apache to serve up a different error page for image content than for html content than for php content since the only command Apache accepts for this is of the &#8220;ErrorDocument error-code document&#8221; format.\u00a0 That said, if you allow .htaccess overrides on a particular directory, then you can specify your ErrorDocument directive in there as well; overriding the default error handling specified in the httpd.conf file.\u00a0 An example:<\/p>\n<p>In my httpd.conf file I have all 404&#8217;s going to errorpage.cgi with the following line:<\/p>\n<p>ErrorDocument 404 \/cgi-bin\/errorpage.cgi<\/p>\n<p>I&#8217;m a good little code monkey and put all of my images in a \/images directory under the DirectoryRoot.\u00a0 By default, if I were to hit a non-existent image in that directory, I would get the default error message defined in the httpd.conf file.\u00a0 If that image were referenced in an html page that I hit, I now download the html page plus the errorpage.cgi page for the bad image reference, introducing one whole page&#8217;s worth of additional overhead.<\/p>\n<p>But since I was a good code monkey and put all of my images in a \/images directory, the fix for this is really simple.\u00a0 I create a .htaccess file inside of my \/images directory and add the following line to it:<\/p>\n<p>ErrorDocument 404 &#8220;404 &#8211; Image does not exist\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;&#8211; Note: No end quote is intentional<\/p>\n<p>Now, if I hit http:\/\/www.mysite.com\/badpage.html I get the errorpage.cgi page, but if I hit http:\/\/www.mysite.com\/images\/badimage.jpg I get a short and sweet message saying &#8220;404 &#8211; Image does not exist&#8221;.\u00a0 I haven&#8217;t tested this yet to see how it works when you are using something like mod_oc4j to send certain URLs to an application server, but it&#8217;s possible that this could work there too if Apache checks for existing static URLs before passing requests to the app server.\u00a0 Further testing could be useful there.<\/p>\n<p>So there you have it.\u00a0 I can&#8217;t tell Apache to serve up different error pages based on the URL or file type, but if I&#8217;m diligent about putting different files under different directories, I can effectively do the same thing using .htaccess files.\u00a0 Woot!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it.\u00a0 What I&#8217;ve come up with is somewhat interesting so I thought I&#8217;d share it with everyone.\u00a0 First, it is not technically possible to tell Apache to serve up a different error [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[96],"tags":[216],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-software-and-tools","tag-apache-errordocument-custom-error-page-htaccess-content-file-type-url"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"I&#039;ve had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I&#039;ve come up with is somewhat interesting so I thought I&#039;d share it with everyone. First, it is not technically possible to tell Apache to serve up a different error\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Josh\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Web Admin Blog | Real Web Admins.  Real World Experience.\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Customizing Apache Error Codes By URL | Web Admin Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"I&#039;ve had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I&#039;ve come up with is somewhat interesting so I thought I&#039;d share it with everyone. First, it is not technically possible to tell Apache to serve up a different error\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2009-02-13T16:12:07+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2009-07-07T17:26:30+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Customizing Apache Error Codes By URL | Web Admin Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I&#039;ve had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I&#039;ve come up with is somewhat interesting so I thought I&#039;d share it with everyone. First, it is not technically possible to tell Apache to serve up a different error\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#article\",\"name\":\"Customizing Apache Error Codes By URL | Web Admin Blog\",\"headline\":\"Customizing Apache Error Codes By URL\",\"author\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/author\\\/jsokol\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/#organization\"},\"datePublished\":\"2009-02-13T11:12:07-06:00\",\"dateModified\":\"2009-07-07T12:26:30-05:00\",\"inLanguage\":\"en-US\",\"commentCount\":1,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#webpage\"},\"articleSection\":\"Software and Tools, apache ErrorDocument custom error page htaccess content\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webadminblog.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/category\\\/software-and-tools\\\/#listItem\",\"name\":\"Software and Tools\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/category\\\/software-and-tools\\\/#listItem\",\"position\":2,\"name\":\"Software and Tools\",\"item\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/category\\\/software-and-tools\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#listItem\",\"name\":\"Customizing Apache Error Codes By URL\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#listItem\",\"position\":3,\"name\":\"Customizing Apache Error Codes By URL\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/category\\\/software-and-tools\\\/#listItem\",\"name\":\"Software and Tools\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/#organization\",\"name\":\"Web Admin Blog\",\"description\":\"Real Web Admins.  Real World Experience.\",\"url\":\"https:\\\/\\\/www.webadminblog.com\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/author\\\/jsokol\\\/#author\",\"url\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/author\\\/jsokol\\\/\",\"name\":\"Josh\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/17951f69795527f90a4e9cb75ad6c9b3?s=96&d=identicon&r=pg\",\"width\":96,\"height\":96,\"caption\":\"Josh\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#webpage\",\"url\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/\",\"name\":\"Customizing Apache Error Codes By URL | Web Admin Blog\",\"description\":\"I've had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I've come up with is somewhat interesting so I thought I'd share it with everyone. First, it is not technically possible to tell Apache to serve up a different error\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/2009\\\/02\\\/13\\\/customizing-apache-error-codes-by-url\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/author\\\/jsokol\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/index.php\\\/author\\\/jsokol\\\/#author\"},\"datePublished\":\"2009-02-13T11:12:07-06:00\",\"dateModified\":\"2009-07-07T12:26:30-05:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/#website\",\"url\":\"https:\\\/\\\/www.webadminblog.com\\\/\",\"name\":\"Web Admin Blog\",\"description\":\"Real Web Admins.  Real World Experience.\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.webadminblog.com\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Customizing Apache Error Codes By URL | Web Admin Blog","description":"I've had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I've come up with is somewhat interesting so I thought I'd share it with everyone. First, it is not technically possible to tell Apache to serve up a different error","canonical_url":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#article","name":"Customizing Apache Error Codes By URL | Web Admin Blog","headline":"Customizing Apache Error Codes By URL","author":{"@id":"https:\/\/www.webadminblog.com\/index.php\/author\/jsokol\/#author"},"publisher":{"@id":"https:\/\/www.webadminblog.com\/#organization"},"datePublished":"2009-02-13T11:12:07-06:00","dateModified":"2009-07-07T12:26:30-05:00","inLanguage":"en-US","commentCount":1,"mainEntityOfPage":{"@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#webpage"},"isPartOf":{"@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#webpage"},"articleSection":"Software and Tools, apache ErrorDocument custom error page htaccess content"},{"@type":"BreadcrumbList","@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com#listItem","position":1,"name":"Home","item":"https:\/\/www.webadminblog.com","nextItem":{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com\/index.php\/category\/software-and-tools\/#listItem","name":"Software and Tools"}},{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com\/index.php\/category\/software-and-tools\/#listItem","position":2,"name":"Software and Tools","item":"https:\/\/www.webadminblog.com\/index.php\/category\/software-and-tools\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#listItem","name":"Customizing Apache Error Codes By URL"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#listItem","position":3,"name":"Customizing Apache Error Codes By URL","previousItem":{"@type":"ListItem","@id":"https:\/\/www.webadminblog.com\/index.php\/category\/software-and-tools\/#listItem","name":"Software and Tools"}}]},{"@type":"Organization","@id":"https:\/\/www.webadminblog.com\/#organization","name":"Web Admin Blog","description":"Real Web Admins.  Real World Experience.","url":"https:\/\/www.webadminblog.com\/"},{"@type":"Person","@id":"https:\/\/www.webadminblog.com\/index.php\/author\/jsokol\/#author","url":"https:\/\/www.webadminblog.com\/index.php\/author\/jsokol\/","name":"Josh","image":{"@type":"ImageObject","@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/17951f69795527f90a4e9cb75ad6c9b3?s=96&d=identicon&r=pg","width":96,"height":96,"caption":"Josh"}},{"@type":"WebPage","@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#webpage","url":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/","name":"Customizing Apache Error Codes By URL | Web Admin Blog","description":"I've had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I've come up with is somewhat interesting so I thought I'd share it with everyone. First, it is not technically possible to tell Apache to serve up a different error","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.webadminblog.com\/#website"},"breadcrumb":{"@id":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/#breadcrumblist"},"author":{"@id":"https:\/\/www.webadminblog.com\/index.php\/author\/jsokol\/#author"},"creator":{"@id":"https:\/\/www.webadminblog.com\/index.php\/author\/jsokol\/#author"},"datePublished":"2009-02-13T11:12:07-06:00","dateModified":"2009-07-07T12:26:30-05:00"},{"@type":"WebSite","@id":"https:\/\/www.webadminblog.com\/#website","url":"https:\/\/www.webadminblog.com\/","name":"Web Admin Blog","description":"Real Web Admins.  Real World Experience.","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.webadminblog.com\/#organization"}}]},"og:locale":"en_US","og:site_name":"Web Admin Blog | Real Web Admins.  Real World Experience.","og:type":"article","og:title":"Customizing Apache Error Codes By URL | Web Admin Blog","og:description":"I've had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I've come up with is somewhat interesting so I thought I'd share it with everyone. First, it is not technically possible to tell Apache to serve up a different error","og:url":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/","article:published_time":"2009-02-13T16:12:07+00:00","article:modified_time":"2009-07-07T17:26:30+00:00","twitter:card":"summary_large_image","twitter:title":"Customizing Apache Error Codes By URL | Web Admin Blog","twitter:description":"I've had a couple of discussions lately about customized Apache error pages that prompted me to do a little bit of research on it. What I've come up with is somewhat interesting so I thought I'd share it with everyone. First, it is not technically possible to tell Apache to serve up a different error"},"aioseo_meta_data":{"post_id":"183","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2025-01-03 22:52:43","updated":"2025-07-17 07:11:20","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.webadminblog.com\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.webadminblog.com\/index.php\/category\/software-and-tools\/\" title=\"Software and Tools\">Software and Tools<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCustomizing Apache Error Codes By URL\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.webadminblog.com"},{"label":"Software and Tools","link":"https:\/\/www.webadminblog.com\/index.php\/category\/software-and-tools\/"},{"label":"Customizing Apache Error Codes By URL","link":"https:\/\/www.webadminblog.com\/index.php\/2009\/02\/13\/customizing-apache-error-codes-by-url\/"}],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pfI0c-2X","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":2,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webadminblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}