[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: RE: mod_rewrite subrequests from mod_perl?
From: "Young, Geoffrey S." <younggs () acwilm ! com>
Date: 1999-07-30 14:12:32
[Download RAW message or body]
ok, mod_rewrite is pretty crazy, but since nobody else has tried to help
yet, I'll give it a stab...
In the docs (available at http://www.apache.org/docs/mod/mod_rewrite.html,
which you probably already know):
'last|L' (last rule)
Stop the rewriting process here and don't apply any more rewriting
rules.
now, I don't know if the "don't apply any more rewriting rules" is just a
generic phrase, or means RewriteRule specifically. Perhaps the RewriteCond
following your first RewriteRule isn't affected by -L? maybe changing
around the order will help.
did you try the -NS flag?
'nosubreq|NS' (used only if no internal sub-request)
This flag forces the rewriting engine to skip a rewriting rule if
the current request is an internal sub-request.
I pretty much use mod_rewrite for simple stuff because it's cool and
convienent, but I'm far from truly understanding it...
hope this helps...
--Geoff
> -----Original Message-----
> From: Jake Buchholz [SMTP:jake@execpc.com]
> Sent: Thursday, July 29, 1999 5:23 PM
> To: modperl@apache.org
> Subject: mod_rewrite subrequests from mod_perl?
>
> I'm trying to set up mod_rewrite to do redirects based on SERVER_NAME,
> and most of those redirects go to a non-existant subdirectory that
> actually is handled by a mod_perl (1.19) handler...
>
> I think I've gotten it working (at least for one SERVER_NAME), but
> some of the RewriteLog output I'm seeing is worrying me a bit.
>
> Anyways, here's the directives I'm using:
>
> |###### mod_rewrite redirects
> |#
> |RewriteEngine On
> |RewriteLogLevel 9
> |RewriteLog /tmp/rewrite.log
> |RewriteMap host-1 txt:/w/config/apache/dev/web-host-1.txt
> |
> |### don't bother with some stuff.
> |#
> |RewriteRule ^/($|perl/|img/|cgi/|index(\.html(\.asis)?)?$) - [L]
> |
> |### Host-1
> |#
> |RewriteCond %{SERVER_NAME} ^host-1(\.some-domain\.com)?$
> |RewriteRule (.*) ${host-1:$1} [C]
> |RewriteRule ^$ %{REQUEST_URI} [L]
> |RewriteRule (.*) http://%{SERVER_NAME}$1 [R=301,L]
>
> Now anything that goes through the mod_perl handler is going through a
> 'subreq' for some reason... Here's the logs when I go to /perl/start...
>
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#8905914/initial] (2) init rewrite engine with
> requested uri /perl/start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#8905914/initial] (3) applying pattern
> '^/($|perl/|img/|cgi/|index(\.html(\.asis)?)?$)' to uri '/perl/start'
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#8905914/initial] (1) pass through /perl/start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) init rewrite engine with
> requested uri /start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (3) applying pattern
> '^/($|perl/|img/|cgi/|in
> |dex(\.html(\.asis)?)?$)' to uri '/start'
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (3) applying pattern '(.*)' to
> uri '/start'
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (4) RewriteCond: input='host-1'
> pattern='^host-1(\.some-domain\.com)?$' => matched
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (6) cache lookup FAILED, forcing
> new map lookup
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (5) map lookup FAILED:
> map=host-1[txt] key=/start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) rewrite /start ->
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (3) applying pattern '^$' to uri
> ''
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) rewrite -> /start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) local path result: /start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) prefixed with document_root
> to /w/content/http/perl/start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (1) go-ahead with
> /w/content/http/perl/start [OK]
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) init rewrite engine with
> requested uri /start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (3) applying pattern
> '^/($|perl/|img/|cgi/|in
> |dex(\.html(\.asis)?)?$)' to uri '/start'
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (3) applying pattern '(.*)' to
> uri '/start'
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (4) RewriteCond: input='host-1'
> pattern='^host-1(\.some-domain\.com)?$' => matched
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (5) cache lookup OK:
> map=host-1[txt] key=/start -> val=
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) rewrite /start ->
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (3) applying pattern '^$' to uri
> ''
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) rewrite -> /start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) local path result: /start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (2) prefixed with document_root
> to /w/content/http/perl/start
> |10.10.10.10 - - [29/Jul/1999:13:57:06 -0500]
> [host-1/sid#8099954][rid#890b944/subreq] (1) go-ahead with
> /w/content/http/perl/start [OK]
>
> The first three log lines make sense to me, but the remainder of these
> log lines I find troublesome. It should already have what it needs,
> why is it doing a subrequest _twice_ with a potentially dangerous
> REQUEST_URI that could result in a loop? (for example, if '/start' was
> in the host-1 map and pointed to '/perl/start'... wouldn't the subreq's
> keep on expanding it to '/perl/perl/start', etc.?
>
> Any way to disable the 'subreq' via mod_rewrite or mod_perl?
>
> Thanks...
>
> --
> Jake Buchholz, ExecPC Sr. Systems Administrator : /~\
> jake@execpc.com -- http://www.execpc.com/~jake : ASCII \ / Against
> Fngrpt PGP262: 29f3322af2da07994dc03fdf1f50aed2 : Ribbon X HTML
> GnuPG: 53d97ab3d279f731e7d2fc1197ca38544423882b : Campaign / \ Mail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic