Jump to content

Archived

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

rossh

$_SERVER['PATH_INFO'] switched off

Recommended Posts

Hi i'm tring to sort out my URL's using $_SERVER['PATH_INFO'] but it seems to be switched off, is configurable in php or apache and if i request that it be switched on will i get refused for security issues etc.?  Also is there a way of telling it's switched off.  I read somewhere you can use print_r ($_SERVER);, when i tried this PATH_INFO was not in the output.

If the hosting service won't switch it on is there an alternative?

Share this post


Link to post
Share on other sites
Not all server variables will be available. Some server variables are only available for certain servers. Such as if you are using IIS server you can grab the username that is logged onto the workstation that is browsing the site, However you cant do this if you are using Apache server.

However having a quick look over at php.net on the PATH_INFO variable I found this:
[quote=http://uk.php.net/manual/en/reserved.variables.php]'PATH_TRANSLATED'

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

        [color=red][b]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.[/b][/color][/quote]
NOTE the text in red.

Share this post


Link to post
Share on other sites
Are you running Apache 2? From what I've read you might have problems using $_SERVER['PATH_INFO'] with Apache 2.



PHP.net says:
[quote]Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO. [/quote]

Dont know what that means, but maybe you should have a look into it if you want to.



Orio.

[b]EDIT- [/b] wildteen88 as faster :PP

Share this post


Link to post
Share on other sites
Come to think of ity ou can probably add [b]AcceptPathInfo On[/b] to htaccess file in root of your websites document root.

Share this post


Link to post
Share on other sites
This might help good luck.

[code]
<?php

//my current url
$path=$_SERVER['SERVER_NAME'];
echo $path;


//my computer ip address
$path=$_SERVER['SERVER_ADDR'];
echo $path;

//my internet ip
$path=$_SERVER['REMOTE_ADDR'];
echo $path;

//my current folder i am in
$path=$_SERVER['DOCUMENT_ROOT'];
echo $path;
?>
[/code]

Share this post


Link to post
Share on other sites
Thanks for getting back to me guys, i tried to include the line in .htaccess but no joy.  I checked Apache and it is version Apache/2.0.53 so you might have something there.

Thanks

Ross

Share this post


Link to post
Share on other sites
There's actually a function for this too I believe.  Try looking up pathinfo(); in the manual...it may be what you're looking for.

Dest

Share this post


Link to post
Share on other sites

×

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.