Welcome to WebmasterWorld Guest from 34.237.76.91

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP script problem after changing server type

$_SERVER["REQUEST_URI"] related

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

Preferred Member

10+ Year Member

joined:May 16, 2003
posts:592
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 21, 2003
posts:1069
votes: 0


You could try $_SERVER['PHP_SELF'].

JAG

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

Preferred Member

10+ Year Member

joined:May 16, 2003
posts:592
votes: 0


Thanks JAG, but PHP_SELF gives me the same result.
2:03 am on Dec 3, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12555
votes: 3


What version of PHP is running on the new server?
7:13 am on Dec 5, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Apr 30, 2006
posts:298
votes: 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?
5:56 pm on Dec 5, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members