I have a file called init.php which I want to get automatically included in each and every HTTP request coming to my server. My server is on LAMP configuration with PHP 5.3 and fast CGI. Any method to achieve this is welcome.
What I have already tried:
I have already tried the auto_prepend_file method with .htaccess file but no success.
I have done the following.
.htaccess File:
php_value auto_prepend_file /home/user/domain.com/init.php
init.php file:
<?php
echo "statement 2";
?>
index.php file:
statement 1
So, now if I visit http://domain.com/ I find only statement 1 getting printed. statement 2 is not getting printed.
Kindly let me know how to correct this or if there is any other way to achieve this.
You can not set PHP ini directives with the
.htaccessmethod with FCGI/CGI. You need to apply the changes within the php.ini or better the user ini files Docs instead.Place a file called
.user.iniinto the document root and add theauto_prepend_fileDocs directive in there:This should do the job for you.