Jump to content
Updating IPB tonight Read more... ×


This topic is now archived and is closed to further replies.


Absolute Includes / Multiple Virtual Hosts

Recommended Posts

Hi All,

I've really been banging my head on the wall with this one. WHen I built my first PHP site a few months ago, I used this little snippet to handle my includes:

[code]<?php include($_SERVER["DOCUMENT_ROOT"].'/_includes/components/header.php'); ?>[/code]

It worked perfectly - any page in any directory could use the same code to get to the include.

Now I have another PHP site to build, so I set up two Virtual Hosts in Apache. Each site now lives in its own directory within the htdocs directory. But now, my nice include code, above, no longer works. The code above resolves to the htdocs directory, instead of the the Virtual Host directory.

How can I code my includes to resolve to the root of the Virtual Host directory? Please help!


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.