.htaccess文件
One of the lessor known and used capabilities of .htaccess files is the ability to prepend and append includes to every page request. Doing so avoids needing to code <?php require('footer.php'); ?>
in every template file you wat to use them in. Here's the .htaccess code:
.htaccess文件的一点已知和使用的功能之一是,可以在每个页面请求之前添加和附加包括。 这样做避免了编写<?php require('footer.php'); ?>
代码<?php require('footer.php'); ?>
您想要在其中使用的每个模板文件中的<?php require('footer.php'); ?>
。这是.htaccess代码:
# Prepend the filephp_value auto_prepend_file "/dir/path/utilities.php"# Append file to bottom of pagephp_value auto_append_file "/dir/path/templates/footer.php"
Now don't mistake this post as me telling you to use this strategy; using this functionality creates a layer of indirection that could confuse a team of developers if they don't all have a grasp of where automatically included files are coming from. Just wanted to let you know this was possible!
现在,请不要误解我告诉您使用此策略的帖子; 使用此功能会创建一个间接层,如果开发人员团队无法完全掌握自动包含的文件的来源,则可能会使他们感到困惑。 只是想让您知道这是可能的!
翻译自:
.htaccess文件