是否可以获取我的“.htaccess”文件的绝对路径?
我用它来加载每个文件中的init.php
。
php_value auto_prepend_file /Applications/XAMPP/xamppfiles/htdocs/init.php
有没有办法让我不必写绝对路径?
像这样,如果
init.php
与.htaccess
文件在同一类别中:php_value auto_prepend_file [ABSOLUTE_PATH_TO_HTACCESS]/init.php
如果可能的话,我该怎么写,但仍要返回一个目录(因为
init.php
在public_html
之外,所以.htaccess
在此)。提前致谢。
最佳答案
假设对接受的答案here的更新响应有效,并且您的相对目录结构如您所描述:
[docroot]
|
\- init.php
|
\- public_html
|
\- .htaccess
|
\- index.php
那么您应该能够通过包含指令将目录上移至您希望添加的
init.php
文件php_value auto_prepend_file ./../init.php
在您的.htaccess文件中。
关于apache - htaccess的绝对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31561191/