LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   PHP include() file paths in Apache virtual hosts (https://www.linuxquestions.org/questions/linux-software-2/php-include-file-paths-in-apache-virtual-hosts-234401/)

tawalker 09-23-2004 02:16 PM

PHP include() file paths in Apache virtual hosts
 
I have a working Apache/PHP/MySQL setup on our home network server (Fedora Core 2), and have just set up a virtual host for developing a new Web site.

On previous PHP sites I've built, I have used PHP's include() function for page elements which are re-used (e.g. menus, meta tags and so on), and I intend to do the same with this site. However, I've come across a problem with the file path I use in the include statements.

Before now, a typical include would look something like this:

Code:

include (/includes/menu.php);
Note the file path here - it says "go back to the site root, go into the includes directory and use the 'menu' code snippet". I specifically want this, so that I can have a page template where I never have to change the file path in the include statements.

This is currently working fine on our existing Web site (on an external server), but when I try this on my home server, the include operation doesn't work at all.

If I try this:

Code:

include (./includes/menu.php);
(i.e. with a relative file path) it works, but this means I would have to change the file path if I create a page off the main site root (e.g. '/subfolder/page.php').

I think this is something to do with the server setup - maybe php.ini. Can anyone please advise me?

Many thanks,
Tim


All times are GMT -5. The time now is 10:44 PM.