mod_rewrite NS flag buggy ?

This is a discussion on mod_rewrite NS flag buggy ? within the Linux Web Servers forums, part of the Web Server and Related Forums category; I have a mod_rewrite infinite loop problem that I think I've distilled down as follows (the real rules are ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-21-2004
Stephen Collyer
 
Posts: n/a
Default mod_rewrite NS flag buggy ?

I have a mod_rewrite infinite loop problem that I think
I've distilled down as follows (the real rules are a bit
more complex):

Given some rewrite rules like:

RewriteCond %{REQUEST_URI} !^/bill
RewriteRule ^(.*)$ /bill [L,NS]

RewriteCond %{REQUEST_URI} !^/fred
RewriteRule ^(.*)$ /fred [L,NS]

it seems to me that the NS flag is never taking affect,
regardless of whether the rules are in .htaccess or conf
file.

What I'm expecting is that if the first rule rewrites to
/bill, then mod_rewrite will start a new subrequest with the
uri /bill and eventually rerun the rules above and match on
the 2nd RewriteCond; however, given that I've specified NS,
then the 2nd RewriteRule should be ignored, leaving the rewrite
to /bill in effect.

Now, the rewrite log seems to show that apache issues a
subrequest after the rewrite to /bill (I can [INTERNAL REQUEST]
in the log file, but the 2nd rule is also processed: NS seems to
be doing nothing.

Can anyone make a sensible comment on this ? I'm not sure
if I'm mis-identifying [INTERNAL REQUEST] with a sub-request
i.e. maybe mod_rewrite doesn't count sub-requests that it
generated itself as true sub-requests ? If so, it seems to me
that it'd be impossible to eliminate a large class of infinite loops.

TIA

Steve Collyer
  #2 (permalink)  
Old 06-22-2004
André Malo
 
Posts: n/a
Default Re: mod_rewrite NS flag buggy ?

* Stephen Collyer <ns_news@netspinner.co.uk> wrote:

> What I'm expecting is that if the first rule rewrites to
> /bill, then mod_rewrite will start a new subrequest with the
> uri /bill and eventually rerun the rules above and match on
> the 2nd RewriteCond; however, given that I've specified NS,
> then the 2nd RewriteRule should be ignored, leaving the rewrite
> to /bill in effect.


Nope. mod_rewrite issues a new internal redirect (in .htaccess) which is a
different thing.

> Now, the rewrite log seems to show that apache issues a
> subrequest after the rewrite to /bill (I can [INTERNAL REQUEST]
> in the log file, but the 2nd rule is also processed: NS seems to
> be doing nothing.


[INTERNAL REDIRECT] is it.

> Can anyone make a sensible comment on this ? I'm not sure
> if I'm mis-identifying [INTERNAL REQUEST] with a sub-request
> i.e. maybe mod_rewrite doesn't count sub-requests that it
> generated itself as true sub-requests ? If so, it seems to me
> that it'd be impossible to eliminate a large class of infinite loops.


The typical way is to check for REDIRECT_ variables, e.g. REDIRECT_STATUS.
(an internal redirect causes most of the original variables to be prefixed
with REDIRECT_).

nd
  #3 (permalink)  
Old 06-22-2004
Stephen Collyer
 
Posts: n/a
Default Re: mod_rewrite NS flag buggy ?

André Malo wrote:

> * Stephen Collyer <ns_news@netspinner.co.uk> wrote:
>
>
>>What I'm expecting is that if the first rule rewrites to
>>/bill, then mod_rewrite will start a new subrequest with the
>>uri /bill and eventually rerun the rules above and match on
>>the 2nd RewriteCond; however, given that I've specified NS,
>>then the 2nd RewriteRule should be ignored, leaving the rewrite
>>to /bill in effect.

>
>
> Nope. mod_rewrite issues a new internal redirect (in .htaccess) which is a
> different thing.


OK, I'm confused. I thought that an internal redirect (as generated by,
say, the mod_perl internal_redirect() function) *was* a sub-request. e.g.
on page 554 of the Stein/MacEachern mod_perl book, it says "A special case
of a sub-request is an internal redirect, ..." and then goes on to describe
the C subrequest API, one of which is ap_internal_redirect().

So it's not clear to me why an internal redirect doesn't trigger NS.

>>Can anyone make a sensible comment on this ? I'm not sure
>>if I'm mis-identifying [INTERNAL REQUEST] with a sub-request
>>i.e. maybe mod_rewrite doesn't count sub-requests that it
>>generated itself as true sub-requests ? If so, it seems to me
>>that it'd be impossible to eliminate a large class of infinite loops.

>
>
> The typical way is to check for REDIRECT_ variables, e.g. REDIRECT_STATUS.
> (an internal redirect causes most of the original variables to be prefixed
> with REDIRECT_).


OK, this sounds useful.

Thanks

Steve Collyer
  #4 (permalink)  
Old 06-23-2004
André Malo
 
Posts: n/a
Default Re: mod_rewrite NS flag buggy ?

* Stephen Collyer <ns_news@netspinner.co.uk> wrote:

> OK, I'm confused. I thought that an internal redirect (as generated by,
> say, the mod_perl internal_redirect() function) *was* a sub-request. e.g.
> on page 554 of the Stein/MacEachern mod_perl book, it says "A special case
> of a sub-request is an internal redirect, ..." and then goes on to
> describe the C subrequest API, one of which is ap_internal_redirect().
>
> So it's not clear to me why an internal redirect doesn't trigger NS.


It's just wrong. Internal Redirects and subrequests are different concepts
at all.

nd
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0