Add syntax highlighting to notes
[disinclined.org.git] / _posts / 2011-03-25-migrating-domains.html
1 ---
2 layout: note
3 ---
4
5 <p>I set up <a href='http://dylanstestserver.com'>dylanstestserver.com</a> as a test domain. It's a pain to type out, so I planned on switching to <a href='http://dylansserver.com'>dylansserver.com</a>. 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.</p>
6
7 <p>First I added a new virtualhost to Apache's httpd.conf.</p>
8
9 <p>I then checked out a new copy of the <i>live</i> branch into a new folder in the webroot.</p>
10
11 <p>Next I added a new A record to my DNS, pointing from the new domain to my elastic IP.</p>
12
13 <p>Then I restarted Apache and checked that the new address worked. Then I replaced the .htaccess in the original DocumentRoot with a new directive.</p>
14 <pre class="brush: bash">
15 v .htaccess
16 ggcG
17 RewriteEngine On
18 RewriteCond %{HTTP_HOST} !^www\.dylansserver\.com$
19 RewriteRule (.*) http://www.dylansserver.com/$1 [R=301,L]
20 </pre>
21
22 <p>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.</p>
23 <pre class="brush: bash">
24 git remote set-url origin git@dylansserver.com:dylansserver
25 </pre>