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

Sum*_*nta 3 html php .htaccess file include

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

这是一个php包含代码:

<?php require('footer.php'); ?>
Run Code Online (Sandbox Code Playgroud)

Pau*_*xon 6

您可以尝试auto_append_file,如下所示

php_value auto_append_file  "footer.php"
Run Code Online (Sandbox Code Playgroud)

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


小智 6

此代码是Prepend the file

php_value auto_prepend_file "/dir/path/utilities.php"
Run Code Online (Sandbox Code Playgroud)

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

php_value auto_append_file "/dir/path/templates/footer.php"
Run Code Online (Sandbox Code Playgroud)

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