httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcus Johansson" <marcus.johans...@surikat.se>
Subject RE: [users@httpd] mod_rewrite - rules loop even though I use the last/L command
Date Thu, 17 Jun 2004 21:07:49 GMT
Thank you very much for your answer!

I have now enabled logging on the highest level and retrieved 38 lines
of logging data. It looks like mod_rewrite makes an "INTERNAL REDIRECT"
and starts the rules all over again after it has processed the rule with
the "L" command.

I don't understand what you mean by adding the (file) to the RewriteRule
and (\w+), can you explain it to me?

I managed to "solve" the problem in a rather "ugly" way:

<Location "/econgero/">
 RewriteEngine On

 RewriteCond       %{REQUEST_URI}          !.*_.*     <--- I added this
line
 RewriteCond       %{QUERY_STRING}         !^$
 RewriteRule       (.*)    $1_%{QUERY_STRING}? [T=text/html]

 RewriteCond       %{REQUEST_URI}          .*,.*
 RewriteRule       (.*),(.*)   $1?$2 [T=text/html]
</Location>

As you can see, this is not the optimum solution, since it only works if
the original URL does NOT contain any underscores, and DOES contain a
questionmark. But since I know and can control the contents of the URL I
think that this will work.

Here are the logs I've got from "RewriteLogLevel 9", I can't find any
obvious way to solve it, but if you can by taking a quick look I would
be grateful for your help!

Regards,
Marcus Johansson

[rid#140180/initial] (2) init rewrite engine with requested uri
/econgero/test
[rid#140180/initial] (1) pass through /econgero/test
[rid#140180/initial] (3) [per-dir /econgero/] applying pattern '(.*)' to
uri '/opt/web/talentboxkaraoke/econgero/test'
[rid#140180/initial] (4) RewriteCond: input='a=1,b=2' pattern='!^$' =>
matched
[rid#140180/initial] (2) [per-dir /econgero/] rewrite
/opt/web/talentboxkaraoke/econgero/test ->
/opt/web/talentboxkaraoke/econgero/test_a=1,b=2?
[rid#140180/initial] (3) split
uri=/opt/web/talentboxkaraoke/econgero/test_a=1,b=2? ->
uri=/opt/web/talentboxkaraoke/econgero/test_a=1,b=2, args=<none>
[rid#140180/initial] (2) [per-dir /econgero/] remember
/opt/web/talentboxkaraoke/econgero/test_a=1,b=2 to have MIME-type
'text/html'
[rid#140180/initial] (3) [per-dir /econgero/] applying pattern
'(.*),(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1,b=2'
[rid#140180/initial] (4) RewriteCond: input='/econgero/test'
pattern='.*,.*' => not-matched
[rid#140180/initial] (2) [per-dir /econgero/] strip document_root
prefix: /opt/web/talentboxkaraoke/econgero/test_a=1,b=2 ->
/econgero/test_a=1,b=2
[rid#140180/initial] (1) [per-dir /econgero/] internal redirect with
/econgero/test_a=1,b=2 [INTERNAL REDIRECT]

[rid#141830/initial/redir#1] (2) init rewrite engine with requested uri
/econgero/test_a=1,b=2
[rid#141830/initial/redir#1] (1) pass through /econgero/test_a=1,b=2
[rid#141830/initial/redir#1] (3) [per-dir /econgero/] applying pattern
'(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1,b=2'
[rid#141830/initial/redir#1] (4) RewriteCond: input='' pattern='!^$' =>
not-matched
[rid#141830/initial/redir#1] (3) [per-dir /econgero/] applying pattern
'(.*),(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1,b=2'
[rid#141830/initial/redir#1] (4) RewriteCond:
input='/econgero/test_a=1,b=2' pattern='.*,.*' => matched
[rid#141830/initial/redir#1] (2) [per-dir /econgero/] rewrite
/opt/web/talentboxkaraoke/econgero/test_a=1,b=2 ->
/opt/web/talentboxkaraoke/econgero/test_a=1?b=2
[rid#141830/initial/redir#1] (3) split
uri=/opt/web/talentboxkaraoke/econgero/test_a=1?b=2 ->
uri=/opt/web/talentboxkaraoke/econgero/test_a=1, args=b=2
[rid#141830/initial/redir#1] (2) [per-dir /econgero/] remember
/opt/web/talentboxkaraoke/econgero/test_a=1 to have MIME-type
'text/html'
[rid#141830/initial/redir#1] (2) [per-dir /econgero/] strip
document_root prefix: /opt/web/talentboxkaraoke/econgero/test_a=1 ->
/econgero/test_a=1
[rid#141830/initial/redir#1] (1) [per-dir /econgero/] internal redirect
with /econgero/test_a=1 [INTERNAL REDIRECT]

I wan't it to stop HERE. When it reaches here it has done exactly what I
want it to do. But it makes an INTERNAL REDIRECT and starts all over
again.

[rid#142a18/initial/redir#2] (2) init rewrite engine with requested uri
/econgero/test_a=1
[rid#142a18/initial/redir#2] (1) pass through /econgero/test_a=1
[rid#142a18/initial/redir#2] (3) [per-dir /econgero/] applying pattern
'(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1'
[rid#142a18/initial/redir#2] (4) RewriteCond: input='b=2' pattern='!^$'
=> matched
[rid#142a18/initial/redir#2] (2) [per-dir /econgero/] rewrite
/opt/web/talentboxkaraoke/econgero/test_a=1 ->
/opt/web/talentboxkaraoke/econgero/test_a=1_b=2?
[rid#142a18/initial/redir#2] (3) split
uri=/opt/web/talentboxkaraoke/econgero/test_a=1_b=2? ->
uri=/opt/web/talentboxkaraoke/econgero/test_a=1_b=2, args=<none>
[rid#142a18/initial/redir#2] (2) [per-dir /econgero/] remember
/opt/web/talentboxkaraoke/econgero/test_a=1_b=2 to have MIME-type
'text/html'
[rid#142a18/initial/redir#2] (3) [per-dir /econgero/] applying pattern
'(.*),(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1_b=2'
[rid#142a18/initial/redir#2] (2) [per-dir /econgero/] strip
document_root prefix: /opt/web/talentboxkaraoke/econgero/test_a=1_b=2 ->
/econgero/test_a=1_b=2
[rid#142a18/initial/redir#2] (1) [per-dir /econgero/] internal redirect
with /econgero/test_a=1_b=2 [INTERNAL REDIRECT]

[rid#1439d0/initial/redir#3] (2) init rewrite engine with requested uri
/econgero/test_a=1_b=2
[rid#1439d0/initial/redir#3] (1) pass through /econgero/test_a=1_b=2
[rid#1439d0/initial/redir#3] (3) [per-dir /econgero/] applying pattern
'(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1_b=2'
[rid#1439d0/initial/redir#3] (4) RewriteCond: input='' pattern='!^$' =>
not-matched
[rid#1439d0/initial/redir#3] (3) [per-dir /econgero/] applying pattern
'(.*),(.*)' to uri '/opt/web/talentboxkaraoke/econgero/test_a=1_b=2'
[rid#1439d0/initial/redir#3] (1) [per-dir /econgero/] pass through
/opt/web/talentboxkaraoke/econgero/test_a=1_b=2



-----Original Message-----
From: Robert Andersson [mailto:robert@profundis.nu] 
Sent: den 17 juni 2004 22:26
To: users@httpd.apache.org
Subject: Re: [users@httpd] mod_rewrite - rules loop even though I use
the last/L command

Have you set the rewrite log to a high enough level? It should reveal
some clues.

> My question to you is:
> Why does the first rule run again, even though I am using the L 
> command on the second rule?

It seems strange, and I cannot say for sure why it doesn't stop there.
Again, the rewrite log might indicate why.

If possible you could attempt modifying the first rule, something like:

    RewriteCond  %{QUERY_STRING}  !^$
    RewriteRule  ^(file)$  $1_%{QUERY_STRING}? [T=text/html]

Of course, replacing "file" with an expression that would match the
original file(s), but not the rewritten, eg: (\w+).

---------------------------------------------------------------------
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


Mime
View raw message