End to mod_rewrite crisis
I have a domain "avisbuttons.com" that shares space with drissman.com at Pair. I was paying $1/month for an extra IP, but with the goodness of mod_rewrite, I figured that I didn't need it as long as I could rely on an HTTP/1.1 header. Sure! So I wrote up:
RewriteCond %{HTTP_HOST} ^(www\.)?avisbuttons\.com$
RewriteRule ^(.*)$ avisbuttonsdotcom/$1
The problem was that it would slap the "avisbuttonsdotcom/" onto the url, and then go fetch it. When fetching it, it would see the host, and slap another "avisbuttonsdotcom/" onto the url, and so on, and so on, until mod_rewrite had the good sense to realize that something wasn't quite right and gave up.
But how do you write a regex that matches a string that doesn't start with a certain pattern, and still group? I googled for hours until I finally found a page at Verio that explains that you don't (thank you Verio!):
RewriteCond %{HTTP_HOST} ^(www\.)?avisbuttons\.com$
RewriteCond %{REQUEST_URI} !avisbuttonsdotcom/
RewriteRule ^(.*)$ avisbuttonsdotcom/$1
Aha! So now I have options. If I have a domain that I just want to grab and not receive email at, I can just grab it, point it at my server, and have mod_rewrite do a redirect (e.g. http://www.indubitablesolutions.com/). And if I have a domain that I want email for or a site for (like http://www.avisbuttons.com/), I can park it on drissman.com (a one-time fee) and do a URL rewrite to a subdirectory.