httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Obitz, Toby" <>
Subject [users@httpd] RE: mod_rewrite and SetHandler
Date Thu, 04 Mar 2004 19:45:07 GMT
I didn't get any responses on this, but I figured I would send the fix
to the list just in case someone else out there has the same issue.

Basically, I was rewriting a URL something similar to:

Incoming request "http://somehost/app/function"

RewriteRule ^app/function$ /cgi-bin/script.cgi

Later on in the httpd.conf I had:

<Location /app>
SetHandler weblogic-handler

The rewrite was working like a champ, but the request was still getting
passed on to the weblogic handler instead of executing the cgi-script.

It turns out the Pass Thru option for RewriteRule takes care of this, so
adding the PT flag at the end of the rule:

RewriteRule ^app/function$ /cgi-bin/script.cgi

Solves my issue.

This is from in the mod_rewrite documentation:

'passthrough|PT' (pass through to next handler)
This flag forces the rewriting 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 be able to post-process the output of RewriteRule
directives by Alias, ScriptAlias, Redirect, etc. directives from other
URI-to-filename translators. A trivial example to show the semantics: If
you want to rewrite /abc to /def via the rewriting engine of mod_rewrite
and then /def to /ghi with mod_alias: 
RewriteRule ^/abc(.*) /def$1 [PT]
Alias /def /ghi 

If you omit the PT flag then mod_rewrite will do its job fine, i.e., it
rewrites uri=/abc/... to filename=/def/... as a full API-compliant
URI-to-filename translator should do. Then mod_alias comes and tries to
do a URI-to-filename transition which will not work. 
Note: You have to use this flag if you want to intermix directives of
different modules which contain URL-to-filename translators. The typical
example is the use of mod_alias and mod_rewrite..

Anyway, that's it.  Hope this helps someone else.


I'm currently using apache 2.0.48 on Solaris 8 and weblogics 6.1 SP4.  I
am trying to do a Rewrite on a url containing the application path, i.e.
in my httpd.conf I have something similar to:

RewriteRule ^/app/login$ /web/cgi-bin/post.cgi

later on I have:

<Location /app>
   SetHandler weblogic-handler
Everything works great, unless I try to get the Rewrite rule to file by
hitting the "login" page.  I would expect the Rewrite rule to rewrite
the URL from "/app/login" to "/web/cgi-bin/post.cgi".  This would then
bypass the Location match for "app".  What I see, however, is that the
Rule fires as it should (from the Rewrite Log): - - [01/Mar/2004:15:47:52 --0500] [HOST
/sid#99b50][rid#11e6e0/initial] (1) go-ahead with /web/cgi-bin/post.cgi
[OK] - - [01/Mar/2004:15:47:52 --0500] [HOST
/sid#99b50][rid#11e6e0/initial] (1) force filename /web/cgi-bin/post.cgi

to have MIME-type 'application/x-httpd-cgi'

However, after this is done, it appears that apache still forwards the
request on to WLS plugin based on the "pre-rewritten" URL with "app" and
the Location directive, not the desired outcome.

Is it possible to Rewrite in this scenario and force the request to go
somewhere other than the handler set up in the Location directive?  Is
there something else that I'm missing?

A few other notes, this worked in Apache version 1.3.29, but hasn't
worked since migrating to 2.0.  Also, the Rewrite to the cgi script
works fine if I comment out the Location directive, or modify the
initial URL to not contain "app".  The cgi script is very simple and
only writes a comment to a log file.  If I hit the cgi script directly,
it works, so there doesn't appear to be a permissions problem.

Any help would be greatly appreciated.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message