Apache Virtual Hosts and Domain Redirection

You want to have the ability to redirect a subdomain but how best to go about it?  One way is to use Apache's Virtual Hosts (especially if you want to avoid using .htaccess), Redirect and the mod_alias module.

I wanted to redirect the entire www subdomain to my root domain so I did the following in my Virtual Host configuration file (located in apache2/sites-available):​

Breaking down the components of the Redirect statement looks like this:​

  • Redirect type: you can use permanent OR 301 as well as any of the other HTTP standard codes for redirect
  • Path to be redirected: I wanted the whole of the website redirected (hence I specified '/' ) but you could just as easily specify a subdirectory
  • URL to be redirect to: If the request had a path that did not exactly match the second argument, then all bits that followed would be appended to the destination URL (e.g. if the request was www.yourdomain.com/taco/bar.html, the redirect would look like yourdomain.com/taco/bar.html

You can still use the Redirect command in .htaccess if you so choose, it's just not my preference.​

Git, Fabric and Python - Tag You're It

There are many discussions that you can read about value of creating 'versions' or 'versioning' software.  More often then not, the versions (e.g. v 1.2.34) are used for marketing purposes or commercial product releases.  Does the internal engineering staff pay attention to such monikers on a daily basis?  Not really.  ​

​There are some instances, however, whereby knowing exactly which files on running on what server can come in handy.  

I wrote this Fabric task that can be called when doing a code push.  It tags the set of files with the name of the host machine the deploy is going to + a unique time stamp.  It also creates a 'tag' file which contains what branch of the code was used for this deployment.