包含.htaccess中的目录路径

时间:2022-09-07 22:51:42

In my .htaccess file

在我的.htaccess文件中

php_value auto_append_file "run_me_first.php"

Because I want to run it first before any other file. Now it works if run_me_first.php and foo.php are in the same directory but once I do something like going in a directory, it gives me this error (include_path='.:/usr/share/php:/usr/share/pear')

因为我想先在任何其他文件之前运行它。现在它可以工作,如果run_me_first.php和foo.php在同一个目录中,但是一旦我做了一些像进入目录,它给了我这个错误(include_path ='。:。/ usr / share / php:/ usr / share /梨')

root
|_ .htaccess
|_ run_me_first.php
|_ foo.php
|_ folder1
   |_ bar.php // If I try to access this, give me the error above.

Any idea?

1 个解决方案

#1


1  

You can set the full path linking to your root folder, to make your rule directory-recursive. You can see the path on your cPanel, or using php function getcwd() in run_me_first.php.

您可以设置链接到根文件夹的完整路径,以使您的规则目录递归。您可以在cPanel上查看路径,或在run_me_first.php中使用php函数getcwd()。

In my case the path would be like this:

在我的情况下,路径将是这样的:

php_value auto_append_file "/home/userID/public_html/run_me_first.php"

Note: If you want to prepend file(in this case your appending the file to the end of every file), use auto_prepend_file instead.

注意:如果要预先添加文件(在这种情况下,将文件附加到每个文件的末尾),请改用auto_prepend_file。

#1


1  

You can set the full path linking to your root folder, to make your rule directory-recursive. You can see the path on your cPanel, or using php function getcwd() in run_me_first.php.

您可以设置链接到根文件夹的完整路径,以使您的规则目录递归。您可以在cPanel上查看路径,或在run_me_first.php中使用php函数getcwd()。

In my case the path would be like this:

在我的情况下,路径将是这样的:

php_value auto_append_file "/home/userID/public_html/run_me_first.php"

Note: If you want to prepend file(in this case your appending the file to the end of every file), use auto_prepend_file instead.

注意:如果要预先添加文件(在这种情况下,将文件附加到每个文件的末尾),请改用auto_prepend_file。