I came across a WordPress quirk I did not know how to solve for some time. Google Webmaster Tools indicated there was a missing index.html on one of my WordPress driven websites. This website is ran on the root domain and was operating as it should be. When visiting a domain (such as mywebsitename.com) what ever is displayed on the page is what appears in the index.html file. When I entered the address of my website with the index.html file, WordPress gave me a 404 error, and this further confused me.
I did some investigation, and found I was not alone in my frustration, but a solution did not exist. While heading to my root domain worked (mywebsitename.com), mywebsitename.com/index.html did not, even weirder mywebsitename.com/index.php performed the job that index.html should have. To solve this problem, my first instinct was to try a simple redirect index.html to index.php by adding code into my .htaccess file. When I added the following code something interesting happened.
RewriteEngine on
RewriteRule index.html index.php [R=301,L]
This solution produced an infinite loop causing the server to terminate the request. This further perplexed me, I needed a solution without creating another webpage that was also SEO friendly. It wasn’t until I came cross this post, detailing how to redirect index.html and index.php to the home page that I found my answer. While the initial instinct was correct, the way to go about it was all wrong, to properly redirect a request for the index.html to the proper page (and make everyone happy), I had to use the following code:
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://nexeusfatale.com/$1 [R=301,L]
By setting this condition, I prevented the server loop, redirected the request to the index.html to the root domain, informed search engines to properly update the missing webpage, and made everyone happy!


