[Catalyst-dev] Advent 2007

Jason Kohles email at jasonkohles.com
Wed Nov 14 01:54:09 GMT 2007


On Nov 13, 2007, at 7:21 PM, Kieren Diment wrote:

> Suggestion for a simple entry for someone who knows about how to use a
> web server and that kind of thing.
>
> I note that vox uses virtual hosts for individual users pages, so
> http://myusername.vox.com.  It would be nice to have  a quick recipe
> with web server config and catalyst code required that shows how to
> use the virtual host as the root controller for your app.  i.e.
> something like this:
>
> http://user1.myapp.com
> http://user2.myapp.com
>


I've done this, but there isn't really anything special you need to do  
in Catalyst to make it work.

All I did was set up a controller to handle the user pages...

sub user : Chained('/') PathPart('user') CaptureArgs(1) { }

And then chained all the user-related pages off that.

Then in the apache configuration...

RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1
RewriteRule ^([^.]+)\.domain\.com(.*) /user/$1$2

This way Apache does all the work, and rewrites foo.domain.com/bar to  
domain.com/user/foo/bar.

The only other thing you need is a DNS record pointing *.domain.com to  
your web server IP.

-- 
Jason Kohles, RHCA RHCDS RHCE
email at jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the Catalyst-dev mailing list