I'm struggling with redirection. We own two domains: uglydomain.com and prettydomain.com. For the longest time our site was only available at uglydomain.com. Recently we purchased prettydomain.com and would like to migrate traffic over to the new domain. Setting it up so folks who browse to prettydomain.com get our content was easy. Where I'm having trouble is with the old url. I'd like anyone who still attempts to access our site at uglydomain.com to be automatically pushed to prettydomain.com. I attempted to do this via 301 in a .htaccess file but I think I'm doing something wrong. Here's what I did:
When I browse to www.uglydomain.com I thought it would push me onto www.prettydomain.com (changing the url in my browser) but no such luck. Do I have the 301 right? What should happen? Thanks in advance for your assistance!
the '?' after the ')' makes the capture group optional, so hidden in g1smd's regexp is that it also matches when HTTP_HOST is exactly null. this is a good thing as it handles the special case of HTTP/1.0 user agent requests.