You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Benoni Jose <ap...@benoni.f2o.org> on 2006/01/15 22:23:27 UTC
[users@httpd] mod_rewrite niggles
Hi,
I was having some problems with mod_rewrite and have made a couple of test
configurations which have isolated the problems I'm having.
The first problem is that each rewrite rule is being repeatidly executed until
it fails, however I thought it should only execute a rewrite rule once. This
is causing problems, as I want to change /index.php to /dir/index.php.
Instead of doing it once it keeps on repeating and then trying to go
to /dir/dir/dir/dir/dir/dir/dir/index.php. Although I could alter the regex
to fix this it would make it much cleaner if I could sort the root of the
problem, as well as clearing up my understanding.
The second problem is that even if I use the flag [L] after a Rewrite rule it
still executes other rules later on in the .htaccess file.
Heres an example that illustrates both:
RewriteRule ^(.*)joe(.*)$ $1luke$2 [L]
RewriteRule ^(.*)luke(.*)$ $1alan$2
Try to go to URI: /joe/joe/joe/joe
Get redirected to /alan/alan/alan/alan
Firstly, it should only change the first instance of joe to luke. If this is
how its meant to work (it doesn't say this in the manual) then how to I turn
it off so it only does it once. Secondly, it shouldn't have changed luke to
alan as the [L] should tell it to end processing.
Any help would be great to find out what wrong, or what I'm doing wrong.
Many thanks
Benoni
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite niggles
Posted by Benoni Jose <ap...@benoni.f2o.org>.
So to clarify a question: Does it loop each RewriteRule or all the RewriteRule
s together?
Thanks
Benoni
On Sunday 15 January 2006 21:29, Joshua Slive wrote:
> On 1/15/06, Benoni Jose <ap...@benoni.f2o.org> wrote:
> > Hi,
> >
> > I was having some problems with mod_rewrite and have made a couple of
> > test configurations which have isolated the problems I'm having.
> >
> > The first problem is that each rewrite rule is being repeatidly executed
> > until it fails, however I thought it should only execute a rewrite rule
> > once. This is causing problems, as I want to change /index.php to
> > /dir/index.php. Instead of doing it once it keeps on repeating and then
> > trying to go to /dir/dir/dir/dir/dir/dir/dir/index.php. Although I could
> > alter the regex to fix this it would make it much cleaner if I could sort
> > the root of the problem, as well as clearing up my understanding.
> >
> > The second problem is that even if I use the flag [L] after a Rewrite
> > rule it still executes other rules later on in the .htaccess file.
>
> Both of these problems are caused by the same thing: your request is
> going through either an internal redirect (subrequest) or an external
> redirect, and this is causing all the rules to be applied again. We
> don't have enough details to figure out why this is happening. The
> RewriteLog would certainly help.
>
> You can tell mod_rewrite not to reprocess rules on internal redirects
> using the [NS] flag.
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite niggles
Posted by Joshua Slive <jo...@slive.ca>.
On 1/15/06, Benoni Jose <ap...@benoni.f2o.org> wrote:
> Hi, Thanks,
>
> What is an internal re-direct? What I presume happens is that once all the
> rewrite rules are processed and we are left with the final URI apache goes to
> fetch that and in doing so starts the whole process off again. Is this
> right?
Not always. Only with certain requests that require it. For example,
if you include a page within an ssi page, then you get a sub-request
that will reprocess the RerwiteRules.
>
> If it is then what is happening is that it will loop through the top rule
> untill there are no more 'joe's. Then because the pattern doesn't match the
> [L] doesn't take effect, so it loops the bottom rule and changes all the
> lukes to alans. Right?
No, that doesn't sound right. But it is impossible to say with
abstract examples like that. Give a real detailed example, and use
the RewriteLog. There is no point in talking about mod_rewrite
problems without consulting the RewriteLog.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite niggles
Posted by Benoni Jose <ap...@benoni.f2o.org>.
Hi, Thanks,
What is an internal re-direct? What I presume happens is that once all the
rewrite rules are processed and we are left with the final URI apache goes to
fetch that and in doing so starts the whole process off again. Is this
right?
If it is then what is happening is that it will loop through the top rule
untill there are no more 'joe's. Then because the pattern doesn't match the
[L] doesn't take effect, so it loops the bottom rule and changes all the
lukes to alans. Right?
Thanks
Benoni
On Sunday 15 January 2006 21:29, Joshua Slive wrote:
> On 1/15/06, Benoni Jose <ap...@benoni.f2o.org> wrote:
> > Hi,
> >
> > I was having some problems with mod_rewrite and have made a couple of
> > test configurations which have isolated the problems I'm having.
> >
> > The first problem is that each rewrite rule is being repeatidly executed
> > until it fails, however I thought it should only execute a rewrite rule
> > once. This is causing problems, as I want to change /index.php to
> > /dir/index.php. Instead of doing it once it keeps on repeating and then
> > trying to go to /dir/dir/dir/dir/dir/dir/dir/index.php. Although I could
> > alter the regex to fix this it would make it much cleaner if I could sort
> > the root of the problem, as well as clearing up my understanding.
> >
> > The second problem is that even if I use the flag [L] after a Rewrite
> > rule it still executes other rules later on in the .htaccess file.
>
> Both of these problems are caused by the same thing: your request is
> going through either an internal redirect (subrequest) or an external
> redirect, and this is causing all the rules to be applied again. We
> don't have enough details to figure out why this is happening. The
> RewriteLog would certainly help.
>
> You can tell mod_rewrite not to reprocess rules on internal redirects
> using the [NS] flag.
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] mod_rewrite niggles
Posted by Joshua Slive <jo...@slive.ca>.
On 1/15/06, Benoni Jose <ap...@benoni.f2o.org> wrote:
> Hi,
>
> I was having some problems with mod_rewrite and have made a couple of test
> configurations which have isolated the problems I'm having.
>
> The first problem is that each rewrite rule is being repeatidly executed until
> it fails, however I thought it should only execute a rewrite rule once. This
> is causing problems, as I want to change /index.php to /dir/index.php.
> Instead of doing it once it keeps on repeating and then trying to go
> to /dir/dir/dir/dir/dir/dir/dir/index.php. Although I could alter the regex
> to fix this it would make it much cleaner if I could sort the root of the
> problem, as well as clearing up my understanding.
>
> The second problem is that even if I use the flag [L] after a Rewrite rule it
> still executes other rules later on in the .htaccess file.
Both of these problems are caused by the same thing: your request is
going through either an internal redirect (subrequest) or an external
redirect, and this is causing all the rules to be applied again. We
don't have enough details to figure out why this is happening. The
RewriteLog would certainly help.
You can tell mod_rewrite not to reprocess rules on internal redirects
using the [NS] flag.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org