Often after converting your website from static HTML to WordPress, you may encounter an issue with your index.html page. Now you could of used default.htm, index.htm or others as the home landing page for your website. It is important to have this property redirected. First so users are not getting a 404 error when finding this page, and second any websites that happen to be linking to your index.html page, you want to take full advantage of those links are direct all this goodness to your root domain.

The Issue Encountered

When migrating a static HTML site to WordPress, There will normally be an index.html, default.htm as so on. Normally with creating a redirect with htaccess, you would employ using the following.

redirect 301 /index.html http://www.example.com/

But if you have tried this, then you are aware this causes a redirect loop and an 500 error code so your page is not loading correctly.

The Resolution

Over the history of your website, you may have had a few different versions/extensions used for your homepage. With the example below, all you have to do is copy the coding. Change the example website url to your own website, and place it at the very beginning of your htaccess file.

Make sure you have a backup file of your htaccess. Just incase something goes wrong and you need to upload the old file quickly.

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.htm
RewriteRule ^(.*)index.htm$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/default.html
RewriteRule ^(.*)default.html$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/default.htm
RewriteRule ^(.*)default.htm$ http://www.example.com/$1 [R=301,L]

Make sure you test out your website to make sure it is loading properly. Also, use Google’s Fetch and Render tool to make sure everything is working properly.