[cgiapp] getting C::A::Dispatch to ignore certain URLs

Michael Peters mpeters at plusthree.com
Mon Jan 26 09:05:34 EST 2009


P Kishor wrote:

> yes, what you say makes sense. My <site folder> has index.cgi, so I
> need to be able to run that with Perl, but, other than that, it is
> only the _perl folder (<site folder>/_perl/) that has the Perl
> modules. I don't really like the cgi-bin setup.

There's a few ways to do this depending on your tastes:

1) Use a <LocationMatch> directive to blanket the whole directory. Something like

   <LocationMatch /img>
     SetHandler default
   </LocationMatch>

Could become verbose if you have a lot of directories to exempt

2) Use a <FilesMatch> directive to cover file types. Something like

   <FilesMatch "\.(jpg|jpeg|png|gif|svg|css|js|xml|pdf|doc|xls|csv|tsv)">
     SetHandler default
   </FilesMatch>

Could be tricky if you do need to dynamically generate images or documents.

3) Put your dynamic stuff under a different URL prefix. I like "/app".

   <Location /app>
     SetHandler perl-script
     PerlHandler MyApp::Dispatch
   </Location>

4) Put your static stuff under a different URL prefix. I like "/static"
   <Location /static>
     SetHandler default
   </Location>

This requires putting your static content into a /static directory though. The upside though is that 
it makes it really easy to control your caching headers for these static assets.

-- 
Michael Peters
Plus Three, LP



More information about the cgiapp mailing list