2011-03-25 / Migrating Domains

I set up dylanstestserver.com as a test domain. It's a pain to type out, so I planned on switching to dylansserver.com. By the time I got around to this though, the first domain has already been indexed by Google. My deployment process was also engrained with the original domain. This is how I made the migration without losing standing in search engines.

First I added a new virtualhost to Apache's httpd.conf.

I then checked out a new copy of the live branch into a new folder in the webroot.

Next I added a new A record to my DNS, pointing from the new domain to my elastic IP.

Then I restarted Apache and checked that the new address worked. Then I replaced the .htaccess in the original DocumentRoot with a new directive.

v .htaccess
ggcG
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.dylansserver\.com$
RewriteRule (.*) http://www.dylansserver.com/$1 [R=301,L]

I moved the repository to it's new folder and changed it's post-recieve hook to reflect the new working directory. I also needed to edit my local gitosis-admin/gitosis.conf (and push the changes) to grant myself access to the new repository. Finally, I updated my local repository to point to the new destination.

git remote set-url origin git@dylansserver.com:dylansserver