I have set apache so that all requests go to a file /var/www/common_index.php
Now, common_index.php looks at requested file name and sources appropriate file
/var/www/123/public_html/requested_file.php
I am having problems when I include a file (with relative path) in requested_file.php. It tries to search for file in /var/www instead of /var/www/123/public_html/
How to solve this?
You can change the working directory in
requested_file.phpbefore callingincludeto make it work:or for PHP 5.3+
If you don’t want to change the working directory (which will affect other file system operations) then just append the path each time you do an include using the magic constant
__DIR__:where the path is relative to the file where you used the code above.