perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Lease Morgan <>
Subject Re: rewriterule, location, and perlhandler [resolved]
Date Wed, 22 Jul 2009 01:50:04 GMT

On Jul 21, 2009, at 9:32 PM, Eric Lease Morgan wrote:

> How do I get Apache's RewriteRule, Location, and PerlHander to work  
> nicely together?...
> I now want to implement a RewriteRule -- a la a "cool" linked data  
> URL -- to redirect URLs with a specific shape to, and  
> I use the following:
>  RewriteRule ^/etexts/id/(.*) /sandbox/semantic-web.cgi?id=$1
> In other words, all request starting with /etexts/id should be  
> redirected (rewritten) to go to semantic-web.cgi. Unfortunately, all  
> requests go directly to the touched file and not to my Perl package;  
> the Location directive seems by-passed....

Resolved. Alas, I needed to add [passthrough] to my RewriteRule  

   RewriteRule ^/etexts/id/(.*) /sandbox/semantic-web.cgi?id=$1  

 From the mod_rewrite documentation:

   * 'passthrough|PT' (pass through to next handler)

   This flag forces the rewrite engine to set the uri field of the
   internal request_rec structure to the value of the filename
   field. This flag is just a hack to enable post-processing of the
   output of RewriteRule directives, using Alias, ScriptAlias,
   Redirect, and other directives from various URI-to-filename
   translators. For example, to rewrite /abc to /def using
   mod_rewrite, and then /def to /ghi using mod_alias:

     RewriteRule ^/abc(.*) /def$1 [PT]
     Alias /def /ghi

   If you omit the PT flag, mod_rewrite will rewrite uri=/abc/... to
   filename=/def/... as a full API-compliant URI-to-filename
   translator should do. Then mod_alias will try to do a
   URI-to-filename transition, which will fail. Note: You must use
   this flag if you want to mix directives from different modules
   which allow URL-to-filename translators. The typical example is
   the use of mod_alias and mod_rewrite.

I sincerely apologize for wasting people's time and bandwidth.

Eric Lease Morgan

View raw message