When I set up this blog, I already had a webserver running serving another domain. It was rather crude httpd.conf setup as managing Apache is not my specialty.
I wanted this domain to work, and to work well. I enlisted the help of a coworker to guide me. What I wanted to do was to make sure that no matter what someone typed in, you ended up at briansblog.net
Follow up:
We ended up with the following:
ServerName briansblog.net
ServerAlias *.briansblog.net
DocumentRoot /Sites/briansblog
ServerSignature On
ProxyRequests Off
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteRule ^/(.*)$ - [E=VHOST:${lowercase:%{HTTP_HOST}}]
RewriteCond %{HTTP_HOST} ^(.*)\.briansblog\.net$
RewriteRule ^/(.*)$ http://briansblog.net/$1 [R,L]
The first three lines ServerName, ServerAlias, and DocumentRoot set up what domains are served, and where to get the files from.
ServerSignature directs apache to add a configuration signature on error pages, so you know where the pages are coming from if there is an error.
ProxyRequests tells apache to not behave as a forwarding proxy, and deny all requests to do so.
RewriteEngine is where you enable the url rewriting capabilities
The first RewriteMap followed by RewriteRule converts the hostname to all lowercase. Doing this makes it easier to match later, and keeps things consistent.
The second set matches the hostname, and takes *.briansblog.net and converts it into http://briansblog.net You will notice if you now type http://foo.briansblog.net you still end up at http://briansblog.net
Recent Comments