I"m struggling to build a site with php includes, that has a directory structure. I've used php includes on single pages, and they work, but as soon as I use directories everything gets messed up. Firstly, here is an example of my directory structure:
root
root/dir1
root/dir2
root/includes
root/index.php
root/dir1/index.php
root/dir2/index.php
root/includes/nav.php
Basically, i'm having problems including 'nav.php' in the index files inside dir1 and dir2. If I have a link in nav.php that looks like:
<a href="index.php">Home.</a>
and then include that file in dir1/index.php using:
<?php include "../includes/nav.php"; ?>
the link takes me to the index file in dir1, not the homepage. THe problem here, is if I link to the homepage with a ../ to go back a directory, the link will not work on pages in the same directory as the homepage.
What i'd like to know, is there a way to tell php to start from the root directory and call all files from the root directory, so that my links work no matter what my directory structure?
Anybody know of a free website template that has a directory structure with multiple directories that I can look at?
Thanks for any and all help!
root
root/dir1
root/dir2
root/includes
root/index.php
root/dir1/index.php
root/dir2/index.php
root/includes/nav.php
Basically, i'm having problems including 'nav.php' in the index files inside dir1 and dir2. If I have a link in nav.php that looks like:
<a href="index.php">Home.</a>
and then include that file in dir1/index.php using:
<?php include "../includes/nav.php"; ?>
the link takes me to the index file in dir1, not the homepage. THe problem here, is if I link to the homepage with a ../ to go back a directory, the link will not work on pages in the same directory as the homepage.
What i'd like to know, is there a way to tell php to start from the root directory and call all files from the root directory, so that my links work no matter what my directory structure?
Anybody know of a free website template that has a directory structure with multiple directories that I can look at?
Thanks for any and all help!