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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
* 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 |
|
|||
|
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 |
|
|||
|
* 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 |