问题
I have a small project in local. I'm working under Windows and with XAMPP. My file directory structure is:
Root directory:
C:\xampp\htdocs\routesUnder this folder, I have my bootstrap.php with the configuration I want to initialize my project.
Public folder:
C:\xampp\htdocs\routes\htdocsUnder this folder I have my index.php and my .htaccess.
Inside this .htaccess I have the following configuration:
php_value include_path .:/routes
php_value auto_prepend_file bootstrap.php
If I do a get_include_path() inside the index.php, it shows ".:/routes".
But the message I get on my web browsers (after typing http://localhost/routes/htdocs
) all the time is:
Fatal error: Unknown: Failed opening required 'bootstrap.php' (include_path='.:/routes') in Unknown on line 0
I have tried a lot of combinations of include_path inside the .htaccess:
php_value include_path ".:/routes" php_value include_path .:../routes php_value include_path ".:./routes" php_value include_path ".:routes" ...
The configuration of my httpd.conf is:
DocumentRoot "C:/xampp/htdocs"
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /routes>
AllowOverride all
</Directory>
If I hard code the info in bootstrap inside the index.php, it works (at least this tells me the requirements inside bootstrap are well configured). I don't know what to do for my project to recognize the bootstrap.php.
What am I missing? What am I doing wrong?
Thank you in advance for your help
回答1:
- First, the
<Directory>
block has no effect for include. Since this is not an Apache query, but rather a preprocessing order. - Second, use absolute paths in your include_path, to make it independent from where your files are sitting.
- Third, make sure the path to
bootstrap.php
is openable by the user your webserver runs as, and that the file itself is readable.
来源:https://stackoverflow.com/questions/18976876/htaccess-php-value-include-path-not-working