简体   繁体   中英

.htaccess php_value include_path not working

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:

  : Unknown: Failed opening required 'bootstrap.php' (include_path='.:/routes') in  on line :未知:在第行的打开所需的“bootstrap.php”(include_path='.:/routes') 失败

I have tried a lot of combinations of include_path inside the .htaccess:

 php_value include_path ".:/routes" \nphp_value include_path .:../routes \nphp_value include_path ".:./routes" \nphp_value include_path ".:routes" \n... 

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

  • 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.

如果您使用的是 Windows,则应该是;

php_value include_path ".;./routes"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM