I used:
php_value auto_prepend_file \"file.php\"
in my .htaccess
that is in public_html
folder.
Now when
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"
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.
Alternatively, just add :/path/to/file_directory
to include_path
directly in the php.ini
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"