BlogMatrix
 

Internals: Using mod_rewrite to let BlogMatrix serve hostnames

edit David P. Janes 2006-07-23 11:13 UTC add comment  ·

One thing I'm planning to do in the very near future is to move my weblog AND my del.icio.us links all over to (semantic.)blogmatrix.com. This will give me a weblog with 5000+ entries and lots of comments to test the edges of our code. I've already offered a bounty to help us write a MovableType converter, though it looks like I'll have to finish writing this myself.

Here's the changes (in bold) I had to make to our primary server's httpd.conf to make this work:

<VirtualHost *:80>
 ServerAlias *.semantic.blogmatrix.com
 ServerAlias weblog.davidjanes.com

 # special rules for users with their own blog name
 RewriteCond %{HTTP_HOST}   ^weblog.davidjanes.com$
 RewriteRule ^.*$           @davidjanes.semantic.blogmatrix.com$0


 # host based rewriting
 RewriteRule ^[@](.+)       $1 [S=1]
 RewriteRule ^.+            %{HTTP_HOST}$0
</VirtualHost>

Notes:

  • "[S=1]" means skip the next line; if we're rewriting for a user host we don't need the standard rule that inserts the username.semantic.blogmatrix.com into the rules
  • We'd just repeat the "# special rules" section as many times as we needed. The RewriteCond only applies to the next line
  • We'll need some way of making this very dynamic so user's can just set up the hostname without operator intervention

There's going to need to be more recognition of the user's preferred host name in the code, but I'll work on this later.

Add Comment