Header and footer via .htaccess
Okay okay, this is in relation to the PHP: Header problems? -- Try the quick fix tutorial.

If you run a free web hosting service, or just need a header and footer on those 2,345 static HTML pages, this tutorial is for you!

Read more to see how it's done.

Let's start off by opening up your .htaccess file (or just create a blank document) and add this line:
php_value auto_prepend_file 'http://yourdomain.com/header.php'
Okay, so that bit means it's going to add the header to any PHP page on your web site instantly. However, this can screw up PHP pages if they use the header() function provided by PHP (and trust me, you don't want that to happen).

So, we can fix that by adding another line to create a buffer.
php_value output_buffering = 5120

5120 - Huh?

5120 means 5KB (kilobytes). This basically means that your content is read from the top of the page, until 5KB has been processed. You may need more depending if you have a large header before you use the header() function.

Remember: 1024 = 1KB (kilobyte)

Now that that's all done, this only works on PHP pages, so now we need to correct this so that HTML pages are executed as PHP pages too. To do this, add this line:
AddType application/x-httpd-php htm html
If you think you might want a footer, you'll have to use auto_append_file instead of auto_prepend_file, or you can use both!

So if you're adding a footer, you'll need to add this line to your .htaccess file.
php_value auto_append_file 'http://yourdomain.com/footer.php'
Once you have done, just save (if you started a new document, save it as '.htaccess' without the quotes) and upload it to your root directory.
SOCIAL BOOKMARK - Posted by Steven Sullivan on 25th August, 2006 - 16:05:17 GMT

Comments

1

Posted by nucleocide on 5th November, 2006 at 05:29:13 GMT


>_
2

Posted by nucleocide on 5th November, 2006 at 05:29:31 GMT


There would be a double tag in each rendered page. My vote would be to have the site put all content into a database, but this is definately a simple solution.
3

Posted by nucleocide on 5th November, 2006 at 05:30:16 GMT


There would be a double body tag in each rendered page. My vote would be to have the site put all content into a database, but this is definately a simple solution.

(Didn't know your script kills gt and lt symbols, hence mangling my comments)
4

Posted by Roosta on 27th March, 2007 at 23:26:02 GMT


Angry


* Name:
* E-Mail:
Not shown to public
Website:
Emotions:
* Comment:

Up

Down

characters left
* Security Code:
Type this code in the box: 34904
* Required field
© Steven Sullivan 2006 - All Rights Reserved         Video Disclaimer - Valid XHTML & CSS