{"id":42148,"date":"2014-12-15T18:54:53","date_gmt":"2014-12-15T13:24:53","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=42148"},"modified":"2026-10-08T19:09:28","modified_gmt":"2026-10-08T13:39:28","slug":"wayback-machine-archive-links-to-404-error-pages","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/","title":{"rendered":"How to Add Wayback Machine Archive Links to 404 Error Pages"},"content":{"rendered":"<p>When a visitor lands on a 404 error page, they usually leave. But if the missing page was ever saved by the Internet Archive, you can offer them a way to still read it. Adding Wayback Machine archive links to 404 error pages gives visitors a link to the last archived copy of the page, so old links from other sites, bookmarks and search results still lead somewhere useful. Here&#8217;s how to do it with a few lines of code, plus when you shouldn&#8217;t.<\/p>\n<p><strong>Quick answer:<\/strong> Add a small script to your theme&#8217;s <code>404.php<\/code> template that asks the Wayback Machine&#8217;s Availability API (<code>https:\/\/archive.org\/wayback\/available?url=<\/code>) whether the missing URL was archived. If it was, show a link to the closest snapshot; if not, show nothing. The Internet Archive also published a ready-made <code>wb404.js<\/code> script for this.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6af30c073ef93\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6af30c073ef93\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#What_the_Wayback_Machine_does\" >What the Wayback Machine does<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#Option_1_The_Internet_Archives_wb404_script\" >Option 1: The Internet Archive&#8217;s wb404 script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#Option_2_Use_the_Wayback_Availability_API_recommended\" >Option 2: Use the Wayback Availability API (recommended)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#Make_your_404_page_more_helpful\" >Make your 404 page more helpful<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#When_not_to_add_archive_links\" >When not to add archive links<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#Frequently_asked_questions\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#Does_linking_to_the_Wayback_Machine_hurt_SEO\" >Does linking to the Wayback Machine hurt SEO?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#What_if_my_page_was_never_archived\" >What if my page was never archived?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/12\/wayback-machine-archive-links-to-404-error-pages\/#Can_I_add_this_without_editing_theme_files\" >Can I add this without editing theme files?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_the_Wayback_Machine_does\"><\/span>What the Wayback Machine does<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <a href=\"https:\/\/web.archive.org\/\" target=\"_blank\" rel=\"noopener\">Wayback Machine<\/a> from the Internet Archive has saved snapshots of hundreds of billions of web pages over the years. It&#8217;s the best way to see how a page looked in the past. When you delete or move pages and can&#8217;t fix every link pointing to them, a link to the archived copy is far better than a dead end.<\/p>\n<p>This is how it looks on our 404 pages:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-42151\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/wayback-links.png\" alt=\"Wayback Machine archive links on a 404 error page\" width=\"499\" height=\"332\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/wayback-links.png 499w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/wayback-links-150x99.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/wayback-links-300x199.png 300w\" sizes=\"(max-width: 499px) 100vw, 499px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Option_1_The_Internet_Archives_wb404_script\"><\/span>Option 1: The Internet Archive&#8217;s wb404 script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The Internet Archive released a <a href=\"https:\/\/blog.archive.org\/2013\/10\/24\/web-archive-404-handler-for-webmasters\/\" target=\"_blank\" rel=\"noopener\">404 handler for webmasters<\/a>: two lines to paste into your 404 template.<\/p>\n<pre><code>&lt;div id=\"wb404\"&gt;&lt;\/div&gt;\r\n&lt;script src=\"https:\/\/archive.org\/web\/wb404.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>In WordPress, add it to your theme&#8217;s <code>404.php<\/code> file (use a child theme so updates don&#8217;t remove it). If the page has an archived copy, the script shows a link to it. If not, it shows nothing and stays out of the way. It&#8217;s an old script, so check it still works on your site after adding it.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Option_2_Use_the_Wayback_Availability_API_recommended\"><\/span>Option 2: Use the Wayback Availability API (recommended)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For more control over the wording and styling, call the Wayback Machine&#8217;s free <a href=\"https:\/\/archive.org\/help\/wayback_api.php\" target=\"_blank\" rel=\"noopener\">Availability API<\/a> yourself:<\/p>\n<pre><code>&lt;p id=\"wayback-link\"&gt;&lt;\/p&gt;\r\n&lt;script&gt;\r\nfetch('https:\/\/archive.org\/wayback\/available?url=' + encodeURIComponent(location.href))\r\n  .then(function (r) { return r.json(); })\r\n  .then(function (d) {\r\n    var s = d.archived_snapshots &amp;&amp; d.archived_snapshots.closest;\r\n    if (s &amp;&amp; s.available) {\r\n      document.getElementById('wayback-link').innerHTML =\r\n        'This page has moved or been removed, but you can ' +\r\n        '&lt;a href=\"' + s.url + '\" rel=\"nofollow\"&gt;read an archived copy on the Wayback Machine&lt;\/a&gt;.';\r\n    }\r\n  });\r\n&lt;\/script&gt;<\/code><\/pre>\n<p>The API returns the closest archived snapshot of the current URL. The script runs only after the page has loaded, so it doesn&#8217;t slow down your 404 page, and visitors without an archived copy see nothing extra.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Make_your_404_page_more_helpful\"><\/span>Make your 404 page more helpful<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>An archive link works best as part of a useful 404 page. Also include:<\/p>\n<ul>\n<li>A short, friendly message explaining the page wasn&#8217;t found.<\/li>\n<li>A <strong>search box<\/strong>, so visitors can look for what they wanted.<\/li>\n<li>Links to your homepage, popular posts and main categories.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"When_not_to_add_archive_links\"><\/span>When not to add archive links<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The code appears on every 404 page that has an archived copy. That&#8217;s not always what you want:<\/p>\n<ul>\n<li>If you deliberately <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2013\/07\/force-404-errors-wordpress\/\">forced 404 errors<\/a> to remove thin or penalised content, you probably don&#8217;t want to send visitors back to it.<\/li>\n<li>If a page is gone for good, a <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/11\/http-410-error-pages-htaccess\/\">410 Gone<\/a> status is clearer for search engines.<\/li>\n<li>If a better page exists, use a <strong>301 redirect<\/strong> instead. It helps visitors and keeps the SEO value of backlinks; see how we <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2020\/03\/link-juice-from-deleted-subdomains\/\">recovered link juice from deleted subdomains<\/a>.<\/li>\n<\/ul>\n<p>Fix broken links on your own site first, too: here&#8217;s how to <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2020\/04\/find-remove-internal-broken-links\/\">remove broken internal links in WordPress<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Does_linking_to_the_Wayback_Machine_hurt_SEO\"><\/span>Does linking to the Wayback Machine hurt SEO?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>No. It&#8217;s a link on a 404 page, which search engines don&#8217;t index. Adding <code>rel=\"nofollow\"<\/code> keeps it neutral.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_if_my_page_was_never_archived\"><\/span>What if my page was never archived?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The script shows nothing. You can ask the Wayback Machine to save important pages now with its <strong>Save Page Now<\/strong> feature at web.archive.org.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_I_add_this_without_editing_theme_files\"><\/span>Can I add this without editing theme files?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes. Some 404 page plugins let you add custom HTML or scripts to the 404 page, or use a code snippets plugin that targets 404 pages.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When a visitor lands on a 404 error page, they usually leave. But if the missing page was ever saved&#8230;<\/p>\n","protected":false},"author":4,"featured_media":42151,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6,41],"tags":[49,17],"class_list":["post-42148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","category-search-engine-optimization","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/42148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=42148"}],"version-history":[{"count":1,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/42148\/revisions"}],"predecessor-version":[{"id":63661,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/42148\/revisions\/63661"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/42151"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=42148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=42148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=42148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}