I wanted to redirect 2 domains. One of the domains, (let’s call it olddomain.com), was listed as the primary domain with Hostgator. The other domain, (let’s call it otherolddomain.com), was in a subdirectory of the primary domain. I thought I could just reuse the oh-so-easy 301 redirect that worked when we moved WordPressGarage.com over to WPGarage.com. Ha!
As it turns out, I got this error:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete
I quickly got on chat with Hostgator and they told me that I had to create a “dummy” domain that doesn’t redirect, (let’s call it dummydomain.com), and set it as the primary domain because you can’t have a redirect on the primary domain if you also want a redirect on subdirectories. Apparently that is what would cause an infinite loop. A dummy domain could be any domain that won’t need a redirect. So, I created a dummy domain, dummydomain.com and set it as the primary domain. I then created an add-on (subdirectory) domain for the former primary domain, olddomain.com, and moved the primary domain folders down to the subdirectory level where olddomain.com is now located. The other domain, otherolddomain.com was fine all along since it was an add-on domain (in a subdirectory).
had Hostgator touch up the htaccess and voila! Here’s what worked:
the .htaccess on the old domains:
In HostGator, here’s how the redirect looked:
I think that the code that we mentioned in an earlier post:
Redirect 301 / http://www.<strong>new</strong>domain.com/<em>
would have worked but I didn’t want to break what worked!
Read more about 301 redirect fun!