Code Snippet

Home » Code Snippets » HTAccess » Append / Prepend Files

Append / Prepend Files

Rather than having to call / include a file you need on every single page, you can have them automatically prepended (top of file) or appended (bottom of file) automatically through your .htaccess file.

php_value auto_prepend_file "/real/path/to/file/functions.php"
php_value auto_append_file "/real/path/to/file/footer.php"

Subscribe to The Thread

  1. johndoe

    nice – you can use also the php.ini for this

  2. mo003akes

    but is it safe???

  3. Seth

    I’m completely new to this stuff… for that one tutorial you did for Kailin Yung, could you use this to get those curly things to appear on the h2 tags? and if so/not, how would you go about doing that?

  4. Seth

    I’m quite new to this stuff. In the tutorial where you made a new theme for Kailin Yung, could this be used to get those curly things onto all the h2 tags? haha i’m trying my hardst to find out how to do that and just cant figure it out.

  5. Sam Purcell

    Hey Chris, this is a very useful tool, so thanks. Now, is there any way to selectively append and prepend files? I have pages where I need no footer or header. Can I include a few lines in my htaccess to negate the action for certain files? Because my htaccess file and all of my files are in the head directory, switching file locations doesn’t seem like it’d work, and I don’t know enough to do anything else. Thanks for the snippet!

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~