我使用的:
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 $
发布评论