Redirecting index.html to the Front Page after Converting to WordPress

by Michael on August 30, 2012 · 0 comments

I recently converted a static site created using RapidWeaver to WordPress. This was a relatively easy process, and the end result was great. However, in looking at the Google Analytics data I spotted a problem.


As it turns out, a number of inbound links were pointing to:

http://www.mydomain.com/index.html

instead of plain old:

http://www.mydomain.com/

And since WordPress doesn’t have an index.html file, this resulted in a 404 error whenever someone clicked through.

My first attempt at fixing this was to set up a simple 301 redirect in .htaccess that pointed the former to the latter, as in:

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

but that resulted in an infinite loop:

This webpage has a redirect loop. The webpage at http://www.mydomain.com/ has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

So I scratched my head for a minute and then headed to Google. And guess what? I pieced together a workable solution.

I ended up adding this to .htaccess:

Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.mydomain.com/$1 [R=301,L]

And it worked perfectly.


{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: