/2012/08/10/Dreamhost-and-an-out-of-box-redirect-loop/
{"item":{"status":"visible","url":"\/2012\/08\/10\/Dreamhost-and-an-out-of-box-redirect-loop\/","trash":"","name":"Dreamhost-and-an-out-of-box-redirect-loop","parent":"","title":"Dreamhost and an out of box redirect loop","date":"2012-08-10 22:53:39","filepath":"posts\/20120810_Dreamhost-and-an-out-of-box-redirect-loop.xml.json","type":"post","content":"<p><img style=\"float: left; margin-left: 10px; margin-right: 10px;\" src=\"http:\/\/www.8bitrobot.com\/media\/uploads\/refresh.png\" alt=\"\" width=\"72\" \/>On a newly managed domain, I ran across a redirect loop immediately after adding the domain in the <a href=\"http:\/\/www.8bitrobot.com\/su\/edit\/Dreamhost-and-an-out-of-box-redirect-loop\/dreamhost.com\">Dreamhost<\/a> panel.<\/p>\n<p>Chrome would complain:<\/p>\n<pre style=\"padding-left: 30px;\"><span style=\"color: #ff6600;\">This webpage has a redirect loop<\/span><\/pre>\n<p>With the following error:<\/p>\n<pre style=\"padding-left: 30px;\"><span style=\"color: #ff6600;\">Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.<\/span><\/pre>\n<p>The problem is Dreamhost's homebrewed method for removing \"www\" from the domain.<\/p>\n<p>To solve the problem, edit the domain and check:<\/p>\n<pre style=\"padding-left: 30px;\"><span style=\"color: #339966;\">Leave it alone: Both http:\/\/www.foo.com\/ and http:\/\/foo.com\/ will work<\/span><\/pre>\n<p>Then add the following to an <em>.htaccess<\/em> file at the domain root directory:<\/p>\n<pre style=\"padding-left: 30px;\">RewriteEngine on \nRewriteCond %{HTTP_HOST} ^www\\.(.+)$ [NC] \nRewriteRule ^(.*)$ http:\/\/%1\/$1 [R=301,L]<\/pre>\n<pre><a href=\"http:\/\/wiki.dreamhost.com\/Removing_the_%22www%22_from_your_domain\"><em>source for the .htaccess file<\/em><\/a><\/pre>"}}