Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not sure if I've posted the title correct as I'm not sure if there's a tehnical title for what I'm looking for - see below.

On my localhost server I have a clone of my VPS files as I wish to sync them via git.

My index.php file contains PHP includes for header and footer:

<?php include(/web/modules/footer.php); ?>

On the VPS the website is hosted inside /home/website. On my localhost (XAMPP on Mac OS X) at htdocs/website.

On localhost the index.php will not load the stylesheets or the footer.php if the / is at the begining of the PHP include.

Is there any way around so I can make XAMPP to behave correctly with /?

Thank you.

share|improve this question

Simply put $_SERVER["DOCUMENT_ROOT"] at the start, for example, <?php include($_SERVER["DOCUMENT_ROOT"] . "/web/modules/footer.php"); ?>

The reason why the slash at the start doesn't work is because you are making PHP look in the root of the drive the script is on for footer.php.

Hope this helps.

share|improve this answer
Is there any other way around? Maybe a way around without modifying the PHP code. Unfortunatelly I'm not using only PHP include, but severals plus some basic links that start with /link and are pointing to my localhost rather than my localhost/website.Thank you. – Lee Mar 14 '11 at 22:55
Another way would be to set the include_path in php.ini to include the folder your include scripts are in. More information available at PHP's Website: – Adam Mar 18 '11 at 22:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.