Add Wayback Machine Archive Links to 404 Error Pages

Would it not be nice if you could have links on 404 Error pages pointing to Wayback machine Archive.org links on how the pages looked like in the past. Of course there can be no better way for doing this than adding a single line of code which will check the 404 link for  an archived url.

The Wayback machine (Archive.org) archives all your websites at different time periods and has true snapshots of your webpages. It is the best way to find how webpages looked like in the past. When your links go awry, and you are not able to fix all of them, why not point visitors to links of how the page actually looked like in the past.

Add Archive.org Links

They suggest you simply add the following code in your 404 page template. In WordPress, you can add in the 404.php file while editing your theme template.

<div id="wb404"/>
<script src="https://archive.org/web/wb404.js"> </script>

Now when a visitor visits a page which has been indexed in the Wayback machine, it will display the link to the latest copy they stored. See how it looks on our 404 pages right now.

wayback archive links

Note:  If it is a random url, and the script cannot find the link, then it will display a blank space and stay out of the way, which is good.

When not to do this? If you add this to your 404 page template, the code will display on all 404 pages which have a Archived link. You would not like to implement this feature if you have purposefully deleted the urls and force 404 errors, to fix Google penalties or maybe the page is actually gone and you want to display a 410 gone error purposefully.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.