.htaccess php_value include_path not working

♀尐吖头ヾ 提交于 2019-12-13 02:08:31

问题


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\routes
Under this folder, I have my bootstrap.php with the configuration I want to initialize my project.

Public folder:

C:\xampp\htdocs\routes\htdocs
Under 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!