I am trying to configure Apache to send most URI's to my mod_perl application with the exception of a few files, which I want to serve using the default handler. (send a static file)

I want all http://myserver.com/xxxxx to go to the mod_perl with /, /index.html, robots.txt and a few subfolders to be served statically.

I have tried a number of different combinations but I can't get it to work. There doesn't appear to be a way to negative < LocationMatches > or the like.

If I define the PERL variable, everything goes to the script, with it off, I can sever the static data, but obviously the script doesn't work.

<Directory /home/httpd/plaintext>
    AllowOverride None
    <Files ~ "(index.html|robots.txt|favicon.gif)">
          SetHandler default-script
        AddDefaultCharset utf-8 
    DirectorySlash off

    Order allow,deny
    Allow from all


<IfDefine PERL>
<Location />
          SetHandler perl-script
          PerlResponseHandler LinkCrunchDB::Handler

I guess hacking the module to use internal redirects might work, but it's ugly.

I am using Gentoo Linux, which includes all files in the module.d/ folder then vhost.d folder. I have checked all of these and removed any Directory or Location folders, there wasn't any!

Many thanks.


This is one of my long-standing annoyances with mod_perl, and ultimately why I'm glad Ruby on Rails came about.

Basically, you cannot share where your Perl scripts live and where the static content lives. They must be in different directories. I often cheated and used a different hostname for the static and dynamic content, which removed the whole issue. You can also read a little bit more about how to put static content in a subdirectory perhaps.

  • So you can't do it that way :-) I suspected as such. – Chris Huang-Leaver Jan 18 '10 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.