You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Gabriel Ambuehl <ga...@buz.ch> on 2003/05/21 13:50:31 UTC

Bug in mod_rewrite? PATH_INFO seems wrong with index.*

Hi list,
(not entirely sure whether I'm right here but please bear with me):

I have the following mod_rewrite rules (apache 1.3.27/mod_ssl 2.8.14):

RewriteEngine On
RewriteLog "/root/rewrite.log"
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} index.php$
RewriteRule (.*\.php.*) /cgi-sys/cgiwrap/ostch_com/forum/$1 [PT,NS,T=application/x-http-cgi,L]
RewriteRule (.*\.cgid.*) /cgi-sys/cgiwrapd/ostch_com/forum/$1 [PT,L]
RewriteRule (.*\.cgi.*) /cgi-sys/cgiwrap/ostch_com/forum/$1 [PT,L]

Everything works fine for normal requests where the script name is
sent to the server by the browser.

A normal request (for forum/test/index.cgid):
Environment Variables:
     QUERY_STRING: ''
      SCRIPT_NAME: '/cgi-sys/cgiwrapd'
  SCRIPT_FILENAME: '/usr/local/www/cgi-bin/cgiwrapd'
     REDIRECT_URL: '<NULL>'
        PATH_INFO: '/ostch_com/forum//test/index.cgid'
  PATH_TRANSLATED: '/usr/local/www/cgi-bin/cgiwrapd/ostch_com/forum//ostch_com/forum//test/index.cgid'
      REMOTE_USER: '<NULL>'
      REMOTE_HOST: '<NULL>'
      REMOTE_ADDR: '217.162.135.22'

rewrite.log:
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) init rewrite engine with requested uri /test/index.cgid
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.php.*)' to uri '/test/index.cgid'
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.cgid.*)' to uri '/test/index.cgid'
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) rewrite /test/index.cgid -> /cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) forcing '/cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid' to get passed through to next API URI-to-filename handler
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) init rewrite engine with requested uri /ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (3) applying pattern '(.*\.cgid.*)' to uri '/ostch_com/forum//test/index.cgid'
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) rewrite /ostch_com/forum//test/index.cgid -> /cgi-sys/cgiwrapd/ostch_com/forum//ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) forcing '/cgi-sys/cgiwrapd/ostch_com/forum//ostch_com/forum//test/index.cgid' to get passed through to next API URI-to-filename handler

i.e. PATH_INFO is correct. PATH_TRANSLATED is messed up but for that
one I currently don't care too much. Note that the last line is
probably responsible for messing up PATH_TRANSLATED. Why is it
rewriting the already rewritten URI again?

Now a request for forum/test (which should (!) invoke the same
script):

Environment Variables:
     QUERY_STRING: ''
      SCRIPT_NAME: '/cgi-sys/cgiwrapd'
  SCRIPT_FILENAME: '/usr/local/www/cgi-bin/cgiwrapd'
     REDIRECT_URL: '/test/'
        PATH_INFO: '/ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid'
  PATH_TRANSLATED: '/usr/local/www/cgi-bin/cgiwrapd/ostch_com/forum//ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid'
      REMOTE_USER: '<NULL>'
      REMOTE_HOST: '<NULL>'
      REMOTE_ADDR: '217.162.135.22'

rewrite.log:
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) init rewrite engine with requested uri /test/
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.php.*)' to uri '/test/'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.cgid.*)' to uri '/test/'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.cgi.*)' to uri '/test/'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (1) pass through /test/
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) init rewrite engine with requested uri /test/index.cgid
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (3) applying pattern '(.*\.cgid.*)' to uri '/test/index.cgid'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) rewrite /test/index.cgid -> /cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) forcing '/cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid' to get passed through to next API URI-to-filename handler


217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#83bc2b0/initial/redir#1] (2) init rewrite engine with requested uri /cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#83bc2b0/initial/redir#1] (3) applying pattern '(.*\.php.*)' to uri '/cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#83bc2b0/initial/redir#1] (3) applying pattern '(.*\.cgid.*)' to uri '/cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#83bc2b0/initial/redir#1] (2) rewrite /cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid -> /cgi-sys/cgiwrapd/ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#83bc2b0/initial/redir#1] (2) forcing '/cgi-sys/cgiwrapd/ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid' to get passed through to next API URI-to-filename handler
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) init rewrite engine with requested uri /ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (3) applying pattern '(.*\.cgid.*)' to uri '/ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid'
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) rewrite /ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid -> /cgi-sys/cgiwrapd/ostch_com/forum//ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
217.162.135.22 - - [21/May/2003:13:41:11 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) forcing '/cgi-sys/cgiwrapd/ostch_com/forum//ostch_com/forum//cgi-sys/cgiwrapd/ostch_com/
      
As one can easily see, the PATH_INFO is totally messed up this time.
I added the two newlines in the middle: If mod_rewrite were to stop there,
everything would be fine, again, I don't understand why it continues
considering I used [L].

I must admit that I agree on mod_rewrite being mostly voodoo so it
might very well be one of my rules causing wreak havoc...


Re: Bug in mod_rewrite? PATH_INFO seems wrong with index.*

Posted by André Malo <nd...@perlig.de>.
* Gabriel Ambuehl wrote:

> I have the following mod_rewrite rules (apache 1.3.27/mod_ssl 2.8.14):

It seems, this rule config is not responsible for the problem, because ...

> RewriteEngine On
> RewriteLog "/root/rewrite.log"
> RewriteLogLevel 9
> RewriteCond %{REQUEST_URI} index.php$
> RewriteRule (.*\.php.*) /cgi-sys/cgiwrap/ostch_com/forum/$1 [PT,NS,T=application/x-http-cgi,L]
> RewriteRule (.*\.cgid.*) /cgi-sys/cgiwrapd/ostch_com/forum/$1 [PT,L]
> RewriteRule (.*\.cgi.*) /cgi-sys/cgiwrap/ostch_com/forum/$1 [PT,L]
> 
> 217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) init rewrite engine with requested uri /test/index.cgid
> 217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.php.*)' to uri '/test/index.cgid'
> 217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (3) applying pattern '(.*\.cgid.*)' to uri '/test/index.cgid'
> 217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) rewrite /test/index.cgid -> /cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid
> 217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#8358038/initial] (2) forcing '/cgi-sys/cgiwrapd/ostch_com/forum//test/index.cgid' to get passed through to next API URI-to-filename handler
> 217.162.135.22 - - [21/May/2003:13:38:28 +0200] [forumtest.ostch.com/sid#892daa0][rid#824b038/subreq] (2) init rewrite engine with requested uri /ostch_com/forum//test/index.cgid

this is a subrequest. Where does it happen? I bet, this also causes the
other problem. What other modules do you have installed and what config? You
may mail me your config privately, if you don't want to publish it.

You may try the NS flag in all of the rules above and see if it solves the
problem for you.

nd
-- 
my @japh = (sub{q~Just~},sub{q~Another~},sub{q~Perl~},sub{q~Hacker~});
my $japh = q[sub japh { }]; print join       #########################
 [ $japh =~ /{(.)}/] -> [0] => map $_ -> ()  #            André Malo #
=> @japh;                                    # http://pub.perlig.de/ #