homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP script problem after changing server type
$_SERVER["REQUEST_URI"] related
Reflection




msg:3176200
 9:24 pm on Dec 2, 2006 (gmt 0)

I recently switched hosting from apache running on windows to unix.

Here is my problem...

On each page I include a script that controls the navigation elements of each page. Ex: inlcude("nav.php")

Within nav.php, I check the path of the page that included nav.php and write the appropriate submenu accordingly. For example, when nav.php is included from: www.mysite.com/bluewidgets/index.php it would find that it was included from a page in the "bluewidgets" section and write the appropriate submenu for bluewidgets.

I was accomplishing this by using $_SERVER["REQUEST_URI"] (within nav.php) to retrieve the path of the page that included nav.php. Since switching hosts $_SERVER["REQUEST_URI"] now returns the path of nav.php(includes/nav.php) and not the page that included nav.php. Does that make sense?

Here is the code I was using within nav.php...

$strArr = explode("/", $_SERVER["REQUEST_URI"]);
$directory = $strArr[sizeof($strArr) - 2];

switch ($directory) {
write appropriate menu...
}

Can anyone offer me some advice?

Thanks

 

justageek




msg:3176332
 12:28 am on Dec 3, 2006 (gmt 0)

You could try $_SERVER['PHP_SELF'].

JAG

Reflection




msg:3176371
 1:34 am on Dec 3, 2006 (gmt 0)

Thanks JAG, but PHP_SELF gives me the same result.

coopster




msg:3176384
 2:03 am on Dec 3, 2006 (gmt 0)

What version of PHP is running on the new server?

pixeltierra




msg:3178367
 7:13 am on Dec 5, 2006 (gmt 0)

I've never had this type of need in my nav systems for a directory. I think you should reconsider your site architecture. Or if that isn't feasible, why not use non-relative links in your nav?

jatar_k




msg:3178901
 5:56 pm on Dec 5, 2006 (gmt 0)

try dumping all the vars in $_SERVER and see what there is

echo '<pre>';
print_r($_SERVER);
echo '</pre>';

As long as you are requesting the including file REQUEST_URI should be from that page as opposed to the actual nav file

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved