Jump to content

[SOLVED] PATH_TRANSLATED and APACHE 2.X


ainoy31

Recommended Posts

Is there any way to get $HTTP_SERVER_VARS['PATH_TRANSLATED'] to work with the apache 2.0 filter like it does with the cgi?  I have searched the web and some suggest going back to using apache 1.3.x.  Others suggest using 'SCRIPT_FILENAME' but no luck.

 

$WEB_ROOT = substr(ereg_replace("[\x5c\]"."[\x5c]","\x5c",$HTTP_SERVER_VARS['PATH_TRANSLATED']), 0 , -strlen( $HTTP_SERVER_VARS['SCRIPT_NAME']));

 

Much appreciation.  AM

 

Link to comment
https://forums.phpfreaks.com/topic/128399-solved-path_translated-and-apache-2x/
Share on other sites

The PHP manual has this to say about it:

 

'PATH_TRANSLATED'

    Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.

 

        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.

 

Also, please note that $HTTP_SERVER_VARS is deprecated in place of $_SERVER.

If anyone is interested, here is the solution to the apache 2 and PATH_TRANSLATED issue.

 

I created a file called jushack.php with the content of:

<?   
if (strlen($JDOCROOT = @getenv("JDOCROOT")))   
{     
$_SERVER["DOCUMENT_ROOT"] = $JDOCROOT;     
apache_setenv("DOCUMENT_ROOT", $JDOCROOT, 1);   
}    
$HTTP_SERVER_VARS['PATH_TRANSLATED'] = $HTTP_SERVER_VARS['SCRIPT_FILENAME'];  
?>

Save this file to your webroot.  Then in the file httpd-vhosts.conf of apache I added these lines of code:

 

<VirtualHost *:80>
ServerAdmin webmaster@**the url of the website goes here like mywebsite.com
DocumentRoot c:/core/webhosts/mywebsite.com/htdocs/
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
php_value auto_prepend_file "/core/webhosts/jushack.php"
ServerName mywebsite.com
ServerAlias mywebsite.com
</VirtualHost>

 

Hope is helps some of you guys out.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.