Archive for August, 2009

Moving das blog to a subdomain

Monday, August 3rd, 2009

OK so I’ve recently moved my blog to a subdomain and noticed that this broke all of the Google search results that I’ve got (dude it’s like 3 hits a month!). No really, search for subversion comments (in Australian pages only) and I’m the sixth result. So to set up the subdomain on my shared host I just used cPanel. That part worked fine, but it meant that all requests to http://www.belfryimages.com.au/2008/03/18/editing-past-log-comments-in-subversion/ got redirected to http://blog.belfryimages.com.au. This was due to the generic .htaccess file that was generated.

To get the old links working I had to rewrite the .htaccess file. This lives where the blog used to be (at belfryimages.com.au/.htaccess):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^belfryimages.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.belfryimages.com.au$
RewriteRule ^(.*)$ http://blog.belfryimages.com.au/$1 [R=301,L]

The joy is made in the last line. The ^(.*)$ part is a simple regex that just copies the entire request part, and the $1 in the http… part copies the request into the address of the new redirect.

– fixed the google assert ;-)