Redirect to a new domain? I'm currently running my drupal site on a subdomain (a.example.com). I would like to temporarily redirect any requests to example.com and www. example.com to a.example.com.

Mark Trapp already offered a great solution using .htaccess files. In this case I would prefer to add a little module code. I was thing about checking $GLOBALS['base_url'] and then redirecting with drupal_goto(). Are those the right functions and which hook would I use?
Maybe you're looking for the Domain 301 Redirect module. Here is a quote about it (from the module's project page):


  ... allows sites to 301 redirect to a domain that is marked as the main domain. This means you can have all subdomains and other domains pointing to the site 301 redirect to a domain that you choose as the main domain. This provides great SEO benefit.