如何在.htaccess中包含php文件?

时间:2013-09-07 13:25:41

标签: php html file .htaccess include

如何使用.htaccess包含php文件?我谷歌它,但我找不到一个很好的教程或代码。

这是一个php包含代码:

<?php require('footer.php'); ?>

2 个答案:

答案 0 :(得分:6)

您可以尝试auto_append_file,如下

php_value auto_append_file  "footer.php"

这会产生在每个PHP脚本之后包含footer.php的效果,我认为这是你想要的?还有auto_prepend_file,它将在每个请求之前包含指定的脚本。

答案 1 :(得分:5)

此代码是Prepend the file

php_value auto_prepend_file "/dir/path/utilities.php"

此代码是将文件附加到页面底部

php_value auto_append_file "/dir/path/templates/footer.php"

我在http://samweby.blogspot.in/2013/07/prepend-and-append-htaccess-file.html链接中找到了这个答案。