.htaccess php_value include_path无效

时间:2022-05-09 11:04:03

I have a small project in local. I'm working under Windows and with XAMPP. My file directory structure is:

我在当地有一个小项目。我在Windows和XAMPP下工作。我的文件目录结构是:

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:

在这个.htaccess里面我有以下配置:

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:

如果我在index.php中执行get_include_path(),它会显示“。:/ routes”。但是我一直在我的网络浏览器上输入的消息(在输入http:// localhost / routes / htdocs之后)是:

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:

我在.htaccess中尝试了很多include_path的组合:

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:

我的httpd.conf的配置是:

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.

如果我在index.php中的bootstrap中硬编码信息,它就可以工作(至少这告诉我bootstrap中的需求配置得很好)。我不知道如何为我的项目识别bootstrap.php。

What am I missing? What am I doing wrong?

我错过了什么?我究竟做错了什么?

Thank you in advance for your help

预先感谢您的帮助

1 个解决方案

#1


0  

  • First, the <Directory> block has no effect for include. Since this is not an Apache query, but rather a preprocessing order.
  • 首先, 块对include没有影响。由于这不是Apache查询,而是预处理顺序。

  • Second, use absolute paths in your include_path, to make it independent from where your files are sitting.
  • 其次,在include_path中使用绝对路径,使其独立于文件所在的位置。

  • Third, make sure the path to bootstrap.php is openable by the user your webserver runs as, and that the file itself is readable.
  • 第三,确保bootstrap.php的路径可以由您的web服务器运行的用户打开,并且文件本身是可读的。

#1


0  

  • First, the <Directory> block has no effect for include. Since this is not an Apache query, but rather a preprocessing order.
  • 首先, 块对include没有影响。由于这不是Apache查询,而是预处理顺序。

  • Second, use absolute paths in your include_path, to make it independent from where your files are sitting.
  • 其次,在include_path中使用绝对路径,使其独立于文件所在的位置。

  • Third, make sure the path to bootstrap.php is openable by the user your webserver runs as, and that the file itself is readable.
  • 第三,确保bootstrap.php的路径可以由您的web服务器运行的用户打开,并且文件本身是可读的。