Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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. –  Max 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: php.net/manual/en/ini.core.php#ini.include-path –  Adam Mar 18 '11 at 22:48
add comment

Your Answer

 
discard

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.