From:             [EMAIL PROTECTED]
Operating system: Win2K Server
PHP version:      4.0.6
PHP Bug Type:     IIS related
Bug description:  PATH_INFO and PATH_TRANSLATED not being correctly set


The scripts that we are running use PATH_INFO to determine where a user is
trying to access, and this became a problem when we switched over from
using Apache to using IIS. Once we made the switch from Apache to IIS we
were getting continual CGI Errors (like virtually every single hit was a
CGI Error) [ and this was not because of permissions ]

As it turns out, the only pages where we would not get a CGI error was the
root page, which had an empty PATH_INFO. Here's an example:

Our root script is /test.php. If I requested /test.php everything would
work fine; However if I requested /test.php/hello/world I
would get a CGI Error (under IIS). Under Apache I would get the proper
results -- it would run /test.php and PATH_INFO would be 

But anyways - after spending some time poking around the PHP source I found
that PHP was trying to execute the wrong file! In the above example, it was
attempting to run /test.php/hello/world instead of /test.php (SCRIPT_NAME
was being to /test.php). To me it looked like IIS was setting PATH_INFO and
PATH_TRANSLATED differently than PHP was expecting, so I made a change the
the source so that it would modify those two until they were in working
order. I'm not sure if my change is correct - but it did fix the

(Note: The problem is independent of the actual script - any script where
you put stuff on the URL in this manner will have this problem)


What follows now is the output that I had PHP give on what it was trying to
run. The first is the original version that didn't work, followed by the
version with the changes that I made, and the proper results:

In both of the cases, the requested URL was:

Original (non-working) version
PHP Output follows

SG(request_info).path_translated: (null)
PATH_INFO      : /test.php/hello/world
SCRIPT_NAME    : /test.php
SG(request_info).request_uri = /test.php/hello/world
php_fopen_primary_script(): filename  =
php_fopen_primary_script(): path_info = /test.php/hello/world


So you can see that in the original request it is trying to run the wrong
script. With the changes I made, I now get the following:

New (working) version
PHP Output follows

SG(request_info).path_translated: C:\web\fcsweb\test.php
PATH_INFO      : /hello/world
SCRIPT_NAME    : /test.php
SG(request_info).request_uri = /hello/world
php_fopen_primary_script(): filename  = C:\web\fcsweb\test.php
php_fopen_primary_script(): path_info = /hello/world


Some more information on our system:

OS: Win2k Server SP1
Webserver: IIS4
PHP: 4.0.6 CGI mode

And finally, the patch for the changes I made to cgi_main.c are at:

I've never submitted a patch before, so I don't know if it's done in the
right manner...

Hopefully I've analyzed this whole issue somewhat correctly... :)


Edit bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to