mod_perl vs. mod_rewrite precedence?

E R <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
I'm trying to figure out how mod_perl and mod_rewrite work together.
This is with Apache 1.3.41, mod_perl 1.30, perl 5.8,9.

It seems that if there is a mod_perl handler installed at a location,
a mod_rewrite rule rewriting that location to another doesn't have any
effect.

Below is a sample httpd.conf file. It installs mod perl handlers at
/perl1 and /perl2. The mod_rewrite rules rewrite /perl2 -> /foo.txt (a
file which exists), /bar -> /foo.txt and /baz -> /perl1.

Here is what I am seeing:

GET /perl2 -> returns the output of the mod-perl handler
GET /bar -> returns the contents of the file foo.txt (as expected)
GET /baz -> returns a 404 error; inspecting the rewrite log file shows
that it is trying to serve the file DOCUMENT_ROOT/perl1

Can anyone explain what is going on?

Thanks,
ER

RewriteEngine On
RewriteLog /tmp/rewrite

RewriteCond %{REQUEST_URI} ^/perl2 [NC]
RewriteRule .* /foo.txt [L]

RewriteCond %{REQUEST_URI} ^/bar [NC]
RewriteRule .* /foo.txt [L]

RewriteCond %{REQUEST_URI} ^/baz [NC]
RewriteRule .* /perl1 [L]

RewriteLogLevel 9

<Perl>
  package MyHandler;
  use Apache::Constants qw(OK);
  sub handler {
    my $r = shift;
    $r->content_type("text/plain");
    $r->print("Now is @{[scalar(localtime(time))]}\n");
    return OK;
  }
  package ApacheReadConfig;
  my $app = {
    SetHandler => 'perl-script',
    PerlHandler => 'MyHandler',
  };
  $Location{'/perl1'} = $app;
  $Location{'/perl2'} = $app;
</Perl>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.