Jump to content

$_SERVER['PATH_INFO'] switched off


rossh

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?
Link to comment
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.
Link to comment
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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.