Firstly just want to say thanks in advance.
I’ve just started converting a more or less static site into a php driven site. I haven’t previously
used php to any great length and I’m seriously having problems setting up includes. I’m working
on localhost at the moment.
My directory/project structure is as the following:
mysite.com/index.php
mysite.com/includes/
mysite.com/category-1/demo.php
mysite.com/category-2/
mysite.com/category-3/
...etc
If at all possible, what I’m trying to do is set the path to the includes via htaccess and then be
able to use that path on any page, in any directory.
I’ve currently got this in my htaccess file in the root directory:
php_value include_path "php"
The implementation below then works a charm when called from files within the root directory.
<?php require_once("some-include.php"); ?>
or
<?php include_once("some-include.php"); ?>
It fails however when includes called in the same manner with files in subdirectories. In order to
get it to work I’ve had to create a separate .htaccess file for each directory and place the following:
php_value include_path "../php"
How can I set the path globally in my main htaccess or php.ini and be able to just implement the
includes without having to use relative paths?
Any suggestions are greatly appreciated at this point.