Apache 2 PHP 5 and $_SERVER("PATH_TRANSLATED")

Hi I have run into the issue with PATH_TRANSLATED.  I have a live server running apache2 and php 4.4.2.  I want to upgrade to PHP 5.1.2.  I have built a second server with Apache2 and PHP 5.1.2 to test the sites for any issues.  So far the only issue I have is to do with PATH_TRANSLATED not being set in PHP 5.1.2.  I have tried using the AcceptPathInfo On directive but this has not fixed the issue.  I cannot cgange the website as they are not mine, I just host them.  The sites work fine on the php 4.4.2 server so I need to get them to run on the PHP 5.1.2 server without modifying the website files.  Can Any tell me how to force Apache 2 with PHP 5.1.2 to populate the PATH_TRANSLATED variable.
LVL 9
DCMBSAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blacksixCommented:
looks like it is changed to comply with CGI standards:

From PHP 5.x changelog at php.net:

PATH_TRANSLATED server variable is no longer set implicitly under Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the same value as the SCRIPT_FILENAME server variable when it is not populated by Apache. This change was made to comply with the » CGI specification. Please refer to » bug #23610 for further information, and see also the $_SERVER['PATH_TRANSLATED'] description in the manual. This issue also affects PHP versions >= 4.3.2.

http://www.php.net/manual/en/migration5.incompatible.php

Also from this page has a little more info at the end:

http://www.php.net/manual/en/reserved.variables.server.php

Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined. Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.
DCMBSAuthor Commented:
Thank you blacksix.  I have seen this documentation and tried using AcceptpathInfo On as suggested  but this still does not result in a value being returned in the PATH_TRANSLATED variable.  Can anyone offer any other suggestions on how to get this variable to return a value ?
Steve BinkCommented:
Are you receiving PATH_INFO correctly?
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

DCMBSAuthor Commented:
No the PATH_INFO does not seem to be populated either.
Steve BinkCommented:
Well, that answers why PATH_TRANSLATED is blank.  

What version of Apache are you using?  How are you declaring the directive?
DCMBSAuthor Commented:
I am using apache 2.  I added the AcceptPathInfo On directive in  etc/apache2/apache2.conf and restarted apache
Steve BinkCommented:
>>> I am using apache 2

What is the complete version number?  Try 'apache2ctl -v'.  Copy/paste the exact configuration line you used in your conf file.
DCMBSAuthor Commented:
Server version: Apache/2.0.55
Server built:   Mar  5 2009 23:52:34


Configuration line in /etc/apache2/apache2.conf is (Copy and Pasted)
AcceptPathInfo On

Restart Apache and run following script
$site["dir"]["root"] = $_SERVER["PATH_TRANSLATED"];
echo "<p>".$site["dir"]["root"]."\n</p>";
echo "<P>load file: ".$site["dir"]["root"].'site.php</P>';
if ( file_exists ( $site["dir"]["root"].'site.php' ) )
//if ( file_exists ( 'site.php' ) )
{
   //echo "<P>Loading File</p>";
   require_once( $site["dir"]["root"].'site.php' );
   //echo "<p>File Loaded</p>";
}
else
{
   echo '<P><b>Error:</b> <i>Could not find the File:</i> '.$site["dir"]["root"].'site.php</p>';
   exit();
}

Output in Browser is

load file: site.php

Error: Could not find the File: site.php

i.e Path is empty.




Steve BinkCommented:
What is the full URL you are using in this example?
DCMBSAuthor Commented:
http://www.sibmar.com

this is mapped in my hosts file to 217.168.150.160 (the problem server)
Steve BinkCommented:
You're not using any additional path information?  PATH_INFO/TRANSLATED should only be populated in those circumstances, e.g., http://www.sibmar.com/myfile.htm/extra/path/info.
DCMBSAuthor Commented:
No additional path info has ever been used

The script above is at the start of the main index.php file for the site and should be executed as the site loads in response to the www.sibmar.com url.
Steve BinkCommented:
There lies the problem.  The CGI specification states that PATH_TRANSLATED should only be populated if PATH_INFO is not blank.  PATH_INFO should only have path information found in the URL *after* the actual resource.  So in the example of http://my.domain.com/phpinfo.php/extra/path/info:

REQUEST_URI=/phpinfo.php/extra/path/info  (the full request after the host; this will also be in SCRIPT_URL)
SCRIPT_NAME=/phpinfo.php  (the resource requested)
PATH_INFO=/extra/path/info  (extra path information in the request)
PATH_TRANSLATED=/var/www/docroot/extra/path/info   (the extra path information translated to the current document root)

The change in behavior you are seeing was actually a fix to the non-standard behavior found in earlier versions.  Later versions of PHP adhere to the specification.  The only (correct) solution here is to re-code the applications to do as well.

The odd thing about your problem is that this behavior was supposed to have been remedied in 4.3.2, which means your apps on 4.4.2 should already be coded to deal with this behavior.  See:

http://www.php.net/manual/en/migration5.incompatible.php

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DCMBSAuthor Commented:
OK it seems the code for site will have to be fixed.  I thought this was the case but I had to get a second opinion.  Many thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.