The solution is pretty simple. I used it on some of my sites which have files nested inside directories, and have subnavs, etc.
set up a variable. I call mine $path2root. I put this variable at the top of everypage on the site. Ofcourse this must be before the include script.
here's how I point to my file with the navigation in it which exists in root/includes
First put this at the top of every page, before the include to the nav file, of course the values would change depending where the file is located. So this file is in root/dir-a/sub-1
$path2root = "../..";
<?php include "$path2root/includes/nav.php" ;?>
and in the nav.php file, the links for my nav would look like this:
<a href="<?php echo "$path2root"; ?>/index.php">Home</a>
And actually I use another $path2root for other things and use $path2nav. Why? well if you are on a page say index.php which is in your root dir. and you have the nav.php included. The user clicks to go to contact.php which also exists on the root dir, the code above goes to the link: /contact.php
Do you see the problem? the slash shouldn't be there, so using $path2nav on everypage for navigation I can do this: (this is for files on the root)
$path2nav = "";
and in includes/nav.php I do:
<a href="<?php echo "$path2nav"; ?>index.php">Home</a>
Fixed! and for pages in root/dir-a set:
$path2nav = "../";
and so on. Hope this helps you and helps you understand how I'm using variables to solve the problem.