It’s the little things… like your website suddenly vanishing.
My website (including this blog) is hosted by Dreamhost, a great company with great service. They offer a lot of one-click installs and generally make it easy to set up a blog or email accounts or mailing lists, etc.
Recently they started offering a free CloudFlare plan to Dreamhost subscribers. CloudFlare offers two benefits: faster webpage loads (by distributing your content across different servers around the world) and community-based protection from spam, bots, crawlers, etc. I thought I’d try it out, so I signed up.
When you check the “CloudFlare” box, Dreamhost warns that you need to allow them to redirect all traffic that comes in as http://mydomain.com/ to http://www.mydomain.com/. This seems harmless enough, and it worked fine for me at first, until I realized that one of my WordPress installations stopped working. Trying to visit http://www.wkiri.com/comphist/ or http://wkiri.com/comphist both resulted in an error: “Too many redirects.” Oddly, my other blog (http://www.wkiri.com/today/) did not have this problem.
I couldn’t find a good, concise description of how to fix this on the web, so I’m posting about it here. Basically, the problem occurs when your WordPress installation has its location specified as http://mydomain.com/something instead of http://www.mydomain.com/something. CloudFlare redirects incoming URL requests to http://www.mydomain.com/, WordPress redirects this to http://mydomain.com/, and so on until the server gets sick of it and tells you “Too many redirects.”
To fix it:
- Turn off CloudFlare (otherwise you can’t get in to your WordPress settings). Go to your Dreamhost panel, click “Manage Domains”, then click “Edit” for the domain in question. Scroll down to “CloudFlare Services” and uncheck the box. Scroll down and click “Change settings.”
- Keep reloading your WordPress site until it works (i.e., the DNS updates propagate).
- Log in to your WordPress site and go to the Dashboard. Click “Settings”. Update the “WordPress Address (URL)” and “Site Address (URL)” fields to have the form http://www.mydomain.com/something. Scroll down and click “Save Changes”.
- You may or may not also need to clear your browser’s cookies for this site.
- Go back to the Dreamhost panel, re-enable CloudFlare, and save settings.
- Everything should now work! (Again, DNS updates have to propagate for CloudFlare to be activated again.)