如何包括所有HTTP请求PHP脚本来服务器 [英] How to include a php script in all HTTP requests coming to the server
问题描述
我的init.php ,我想获得自动包含在每来我的服务器的HTTP请求名为的文件。我的服务器是用PHP 5.3和快速的CGI灯配置。实现这一目标的任何方法是值得欢迎的。
我已经尝试过什么:
我已经尝试过 AUTO_ prepend_file
方法的.htaccess
文件,但没有成功
我也做了以下内容。
的.htaccess
文件:
php_value AUTO_ prepend_file /home/user/domain.com/init.php
的init.php
文件:
< PHP
回声语句2;
?>
的index.php
文件:
语句1
所以,现在如果我访问 http://domain.com/ 我觉得唯一的语句1入门打印。声明2不获取打印出来。
请让我知道如何纠正这种或有实现这一目标的任何其他方式。
我的服务器上使用PHP 5.3和快速的CGI灯配置。
您不能设置PHP INI指令与的.htaccess
法FCGI / CGI。您需要申请在php.ini或更好的用户INI文件 文档的 代替。
将一个名为 .user.ini
到文档根目录和添加的 AUTO_ prepend_file
的文档的 指令中有:
AUTO_ prepend_file = /home/user/domain.com/init.php
这应该做的工作给你。
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.
My server is on LAMP configuration with PHP 5.3 and fast CGI.
You can not set PHP ini directives with the .htaccess
method 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.ini
into the document root and add the auto_prepend_file
Docs directive in there:
auto_prepend_file = /home/user/domain.com/init.php
This should do the job for you.
这篇关于如何包括所有HTTP请求PHP脚本来服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!