[Catalyst] Serving server-dependent static content

Andy Grundman andy at hybridized.org
Sun Aug 12 20:49:40 GMT 2007

On Aug 12, 2007, at 2:22 PM, Peter Lytle wrote:

> Good afternoon - I am working on a Catalyst application that serves  
> dynamic website content for multiple sites, and I've run into some  
> difficulty about static content.  Each website has unique static  
> content (images, css, rss) and I am trying to serve that static  
> content from the site's unique directory.  I have found lots of  
> documentation on how to serve all static content from a single  
> directory, but not much on a servername-dependent directory.  For  
> example:
> Request:  http://www.timjohnson.com/css/global.css
> Should be served with:  /var/www/html/sites/timjohnson.com/css/ 
> global.css
> I came close to making this happen just using the Alias directive  
> in httpd.conf, but I couldn't get that to accept a variable, % 
> {SERVER_NAME}, in it.  If someone has a solution from the Apache  
> side, that's fine but I suspect that it might be easier to do this  
> with Catalyst::Plugin::Static::Simple, though I again have not  
> figured out how to tell it to use a variable name when it creates  
> the path the request is supposed to be mapped to.  I am sending  
> this to the Catalyst list because I suspect it might be something  
> other people have faced before using Catalyst.
> My setup is a recent version of Catalyst running on Apache 2.2 with  
> mod_perl.  Any suggestions would be quite welcome - thank you very  
> much.

As has already been said, you should use Apache for this.  But if you  
*really* want to use Static::Simple, take a look at the docs for the  
"Including additional directories", and in particular the  
incpath_generator sample code.  You can write a bit of code that  
returns one or more directories from which to serve static content.


More information about the Catalyst mailing list