使用相对htaccess的,以htaccess文件ppened PHP文件自动$ P $

编程入门 行业动态 更新时间:2024-10-23 23:31:33
本文介绍了使用相对htaccess的,以htaccess文件ppened PHP文件自动$ P $的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的:

php_value auto_prepend_file "file.php"

在我的的.htaccess 是在的public_html 文件夹。

现在当我运行的public_html /子/ index.php文件我得到这个错误:

now when i run public_html/sub/index.php i get this error :

Fatal error: Unknown: Failed opening required 'file.php'

如何使用 AUTO_ prepend_file 标志包含文件相对于的.htaccess 文件?

how to use auto_prepend_file flag to include a file relative to .htaccess file ?

推荐答案

该文件必须是PHP里面的的include_path 。因此,您必须设置文件的目录是在的include_path 在php.ini,或做它用。htaccess的 php_value 语句。

The file must be inside PHP's include_path. So you must either set the file's directory to be in the include_path inside php.ini, or do it in the .htaccess with a php_value statement.

php_value include_path ".:/path/to/file_directory" php_value auto_prepend_file "file.php"

如果您使用的.htaccess上述方法时,一定要复制的include_path 从php.ini文件中,并添加:/ path_to / file_directory 这样你就不会丢失任何既需要包括。

If you use the above method in .htaccess, be sure to copy the include_path from php.ini in and add the :/path_to/file_directory so you don't lose any already needed includes.

另外,只需添加:/路径/要/ file_directory 到的include_path 直接在php.ini

Alternatively, just add :/path/to/file_directory to include_path directly in the php.ini

如果您不能修改的include_path,你可以尝试指定的 AUTO_ prepend_file 的相对路径。这应该工作,因为发送的文件路径相同的处理,就好像它被称为与要求():

If you cannot modify the include_path, you might try specifying a relative path to the auto_prepend_file. This should work since the file path sent is processed identically as if it was called with require():

php_value auto_prepend_file "./file.php"

更多推荐

使用相对htaccess的,以htaccess文件ppened PHP文件自动$ P $

本文发布于:2023-10-31 16:31:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546642.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   htaccess   PHP   ppened

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!