There are literally thousands of search results in Google for how to do a 301 redirect, but the ones that show you specifically how to redirect index.html after migrating to WordPress are buried and difficult to find among all the other 301 tutorials.

Being the SEO geek that I am, I had to create this page for no other reason than have a way for myself to access the code quickly in the future.

The Problem

When you migrate a static HTML website to WordPress, in many cases the static website included a file called index.htm or index.html. If index.html, index.aspx, or index.cfm is indexed in the search results, it will produce a 404 error after you upgrade to a platform like WordPress.

As a Webmaster, you might think that simply adding this code to .htaccess would fix the problem:

RedirectPermanent /index.html

You’ll find doing this creates an endless loop and breaks your website. The other pages will redirect to their new pages just fine, but the index page remains a real pain.

The Solution

Pop the following line of code into your .htaccess and problem solved:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.html HTTP/
RewriteRule ^(([^/]+/)*)index.html$$1 [R=301,L]

Why Bother Redirecting?

Consider the possibly hundreds or thousands of links you might have pointing to index.html. Google’s PageRank™ algorithm is structured mainly around popularity (links, mentions, CTR and overall visibility). If Google’s determination of where to rank your website is dependent on your website’s popularity, why send all of those potential links to a 404 error page? Think about it. Redirection saves your PageRank™ and could save your ranking in the search results.

Thanks for reading.