rossh Posted September 20, 2006 Share Posted September 20, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/ Share on other sites More sharing options...
wildteen88 Posted September 20, 2006 Share Posted September 20, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/#findComment-95456 Share on other sites More sharing options...
Orio Posted September 20, 2006 Share Posted September 20, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/#findComment-95457 Share on other sites More sharing options...
wildteen88 Posted September 20, 2006 Share Posted September 20, 2006 Come to think of ity ou can probably add [b]AcceptPathInfo On[/b] to htaccess file in root of your websites document root. Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/#findComment-95468 Share on other sites More sharing options...
redarrow Posted September 20, 2006 Share Posted September 20, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/#findComment-95473 Share on other sites More sharing options...
rossh Posted September 20, 2006 Author Share Posted September 20, 2006 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.ThanksRoss Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/#findComment-95641 Share on other sites More sharing options...
Destruction Posted September 20, 2006 Share Posted September 20, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/21427-_serverpath_info-switched-off/#findComment-95651 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.