{"id":1333,"date":"2024-05-14T06:46:35","date_gmt":"2024-05-14T06:46:35","guid":{"rendered":"https:\/\/www.cyberrafting.com\/blog\/?p=1333"},"modified":"2024-05-14T06:46:36","modified_gmt":"2024-05-14T06:46:36","slug":"redirect-all-404-pages-using-htaccess-code","status":"publish","type":"post","link":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/","title":{"rendered":"Redirect all 404 pages using .htaccess [code]"},"content":{"rendered":"\n<p>To redirect all 404 (Not Found) errors to a custom page using<strong> .htaccess<\/strong>, you need to use the ErrorDocument directive. <\/p>\n\n\n\n<p><strong>Here\u2019s how you can do it:<\/strong><\/p>\n\n\n\n<p>Create a custom 404 page: Make a new HTML or PHP file that will serve as your 404 error page. For example, let&#8217;s call it 404.html.<\/p>\n\n\n\n<p>Modify your .htaccess file: Add the following lines to your .htaccess file, which is typically located in the root directory of your website.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ErrorDocument 404 \/404.html\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Here\u2019s a step-by-step guide:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Access your <code>.htaccess<\/code> file<\/strong>:\n<ul class=\"wp-block-list\">\n<li>If you\u2019re using an FTP client, navigate to the root directory of your website.<\/li>\n\n\n\n<li>If you\u2019re using a control panel like cPanel, use the File Manager to locate the <code>.htaccess<\/code> file.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Edit the <code>.htaccess<\/code> file<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Open the <code>.htaccess<\/code> file in a text editor.<\/li>\n\n\n\n<li>Add the line: <code>ErrorDocument 404 \/404.html<\/code><\/li>\n\n\n\n<li>Save the changes.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Create the custom 404 page<\/strong>:\n<ul class=\"wp-block-list\">\n<li>In your website\u2019s root directory, create a new file named <code>404.html<\/code>.<\/li>\n\n\n\n<li>Add your custom HTML content for the 404 error page.<\/li>\n\n\n\n<li>Save the file.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>To redirect all 404 (Not Found) errors to a custom page using .htaccess, you need to use the ErrorDocument directive. Here\u2019s how you can do it: Create a custom 404 page: Make a new HTML or PHP file that will serve as your 404 error page. For example, let&#8217;s call it 404.html. Modify your .htaccess [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-1333","post","type-post","status-publish","format-standard","hentry","category-how-to","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Redirect all 404 pages using .htaccess [code]<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Redirect all 404 pages using .htaccess [code]\" \/>\n<meta property=\"og:description\" content=\"To redirect all 404 (Not Found) errors to a custom page using .htaccess, you need to use the ErrorDocument directive. Here\u2019s how you can do it: Create a custom 404 page: Make a new HTML or PHP file that will serve as your 404 error page. For example, let&#8217;s call it 404.html. Modify your .htaccess [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Cyber Rafting\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-14T06:46:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-14T06:46:36+00:00\" \/>\n<meta name=\"author\" content=\"cyberrafting\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cyberrafting\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/\"},\"author\":{\"name\":\"cyberrafting\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#\\\/schema\\\/person\\\/0533280d6685c57435a3151c387fff99\"},\"headline\":\"Redirect all 404 pages using .htaccess [code]\",\"datePublished\":\"2024-05-14T06:46:35+00:00\",\"dateModified\":\"2024-05-14T06:46:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/\"},\"wordCount\":163,\"commentCount\":0,\"articleSection\":[\"How To\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/\",\"url\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/\",\"name\":\"Redirect all 404 pages using .htaccess [code]\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#website\"},\"datePublished\":\"2024-05-14T06:46:35+00:00\",\"dateModified\":\"2024-05-14T06:46:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#\\\/schema\\\/person\\\/0533280d6685c57435a3151c387fff99\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/how-to\\\/redirect-all-404-pages-using-htaccess-code\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Redirect all 404 pages using .htaccess [code]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/\",\"name\":\"Cyber Rafting Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.cyberrafting.com\\\/blog\\\/#\\\/schema\\\/person\\\/0533280d6685c57435a3151c387fff99\",\"name\":\"cyberrafting\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g\",\"caption\":\"cyberrafting\"},\"sameAs\":[\"https:\\\/\\\/www.cyberrafting.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Redirect all 404 pages using .htaccess [code]","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/","og_locale":"en_US","og_type":"article","og_title":"Redirect all 404 pages using .htaccess [code]","og_description":"To redirect all 404 (Not Found) errors to a custom page using .htaccess, you need to use the ErrorDocument directive. Here\u2019s how you can do it: Create a custom 404 page: Make a new HTML or PHP file that will serve as your 404 error page. For example, let&#8217;s call it 404.html. Modify your .htaccess [&hellip;]","og_url":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/","og_site_name":"Cyber Rafting","article_published_time":"2024-05-14T06:46:35+00:00","article_modified_time":"2024-05-14T06:46:36+00:00","author":"cyberrafting","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cyberrafting","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/#article","isPartOf":{"@id":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/"},"author":{"name":"cyberrafting","@id":"https:\/\/www.cyberrafting.com\/blog\/#\/schema\/person\/0533280d6685c57435a3151c387fff99"},"headline":"Redirect all 404 pages using .htaccess [code]","datePublished":"2024-05-14T06:46:35+00:00","dateModified":"2024-05-14T06:46:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/"},"wordCount":163,"commentCount":0,"articleSection":["How To"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/","url":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/","name":"Redirect all 404 pages using .htaccess [code]","isPartOf":{"@id":"https:\/\/www.cyberrafting.com\/blog\/#website"},"datePublished":"2024-05-14T06:46:35+00:00","dateModified":"2024-05-14T06:46:36+00:00","author":{"@id":"https:\/\/www.cyberrafting.com\/blog\/#\/schema\/person\/0533280d6685c57435a3151c387fff99"},"breadcrumb":{"@id":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.cyberrafting.com\/blog\/how-to\/redirect-all-404-pages-using-htaccess-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cyberrafting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Redirect all 404 pages using .htaccess [code]"}]},{"@type":"WebSite","@id":"https:\/\/www.cyberrafting.com\/blog\/#website","url":"https:\/\/www.cyberrafting.com\/blog\/","name":"Cyber Rafting Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cyberrafting.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.cyberrafting.com\/blog\/#\/schema\/person\/0533280d6685c57435a3151c387fff99","name":"cyberrafting","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c1f1c30a5a84d51fe015a59038822cd67358fd7fa1e202f74b946af36798f286?s=96&d=mm&r=g","caption":"cyberrafting"},"sameAs":["https:\/\/www.cyberrafting.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts\/1333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/comments?post=1333"}],"version-history":[{"count":1,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts\/1333\/revisions"}],"predecessor-version":[{"id":1334,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/posts\/1333\/revisions\/1334"}],"wp:attachment":[{"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/media?parent=1333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/categories?post=1333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyberrafting.com\/blog\/wp-json\/wp\/v2\/tags?post=1333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}