Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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.

share|improve this question
up vote 1 down vote accepted

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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