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.
Posted by Steven Sullivan on 25th August, 2006 - 16:05:17 GMT