Maybe it's something I'm doing wrong, but here is the extent of the issues I'm still having.
Here is my directory structure for XAMPP's root:
- Code: Select all
c:\program files\xampp\htdocs
I have a website I'm working on inside that, like so:
- Code: Select all
c:\program files\xampp\htdocs\mysite
c:\program files\xampp\htdocs\mysite\inc
c:\program files\xampp\htdocs\mysite\img
c:\program files\xampp\htdocs\mysite\events
I create an
index.php inside the
mysite directory. This allows me to access it via
http://localhost/mysite. Here is some example code from that
index.php file:
- Code: Select all
<link rel="stylesheet" type="text/css" href="/screen.css" />
...
<div id="sidebar">
<?php include("inc/menu.php"); ?>
<a class="hide" href="#top" accesskey="1">Top of page</a>
<?php include("inc/whatsnew.php"); ?>
</div>
<div class="clear"> </div>
</div>
<div id="footer"><?php include("inc/footer.php"); ?></div>
Before our discussion, I had the PHP Include statements as
<?php include($_SERVER['DOCUMENT_ROOT'] . "/inc/menu.php"); ?>.
Here is some code of the
menu.php file:
- Code: Select all
<h2 class="sidelink menuheader"><a id="sitemenu"></a>Site menu:</h2>
<a class="sidelink" href="/meetings">Meetings</a>
<span class="hide"> | </span>
<a class="sidelink" href="/bylaws">Bylaws</a>
<span class="hide"> | </span>
<a class="sidelink" href="/members" title="This area is password protected">Members</a>
<span class="hide"> | </span>
<a class="sidelink" href="/contactus">Contact Us</a>
<span class="hide"> | </span>
There are multiple issues that I am having trouble getting around. First is the PHP Includes. They work fine for this particular
mysite\index.php file, because the reference to the
inc folder is relative. However, once I create a php file within a subdirectory, say
mysite\meetings\index.php, those include statements stop working. Rightly so, because they aren't relative to the meetings directory. So I code in the absolute paths for
mysite\meetings\index.php like so:
- Code: Select all
<?php include("/inc/whatsnew.php"); ?>
But that doesn't work, because it thinks the absolute path begins at
htdocs and spits it out as
htdocs\inc\whatsnew.php, but I need it to do
htdocs\mysite\inc\whatsnew.php.
My next issues are with the
menu.php file. It has to include absolute paths, because it's being referenced all over the site. Once again, I get the same issue, because since I am using the "/" for the absolute path, it goes back to
htdocs before looking for the
inc folder, when I want it going to
mysite.
Do you see how I cannot make paths correctly using this? When I am under the
htdocs\mysite directory, I want all the "/" absolute paths to start at
mysite, not
htdocs.
That's why I was asking if there is a way to set the root folder as
mysite\ for only the files under
mysite.
I really do appreciate your help. If there is something I am doing wrong or not getting or not explaining well enough, please let me know. Thanks.