WordPress Redirecting Index.html to WordPress Root Domain

About The Author
Cabe Nolan is the founder of WP Cover where he shares his insight into WordPress, development, & entrepreneurship. Outside of WPCover, Cabe continues to run a successful WordPress development firm, Bold City Design as well as a few high profile websites, Arrivala, Two Way Resume, Dock Skipper, and a successful outdoors brand, DolfinPack.

WordPress Redirecting Index.html to WordPress Root Domain

Quick code snippet for you this afternoon. We recently re-designed a website for a company that previously utilized a separate mobile site. In doing so it was important to create 301 redirects for the mobile URLs to the new responsive WordPress site that was created in its place. The mobile site homepage was located at index.html, pretty standard. I figured I would simply add a basic redirect:

Redirect 301 /index.html http://www.yourwebsite.com

Uh oh, redirect error!

This webpage has a redirect loop.

The webpage at http://www.—.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.

After a little bit of troubleshooting, I came up with a simple resolution. For anybody else who experiences this issue, here is the proper .htaccess redirect:

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


Share Your Thoughts

Leave a Reply

Your email address will not be published.

Related Stuff You Might Like

WordPress News, Tips, & Code Snippets

Join the WP Cover mailing list and get wordpress news, tips, code snippets, security warnings, and more delivered right to your inbox.  We won't flood your inbox, newsletters typically go out every 1-2 weeks unless it involves an important security release.

You have Successfully Subscribed!