![]() |
How to add header and footer with .htaccess
Help, i need to use .htaccess to inser headers and footers.
Anyone here that know the code to insert? Stein |
I use php or ssi to add headers and footers not htaccess.
|
The Apache module is called mod_layout.
|
That is what I love about this business, always something new to learn. :)
|
Hmm i dont know shit about php and ssi.
tried an acces file with Header Add Name header.html Footer Add Name footer.html And got an 500 error. I still have much to learn Stein |
PHP seems the simplest way. Construct your html pages as you normally would but name each one whatever.php instead of whatever.html. On each php page, you'll place an include tag on top for your header like this:
include("header.html"); ?> At the bottom, where you want your footer to be, you'll place this: include("footer.html"); ?> Obviously, you'll need to build your header.html and footer.html pages. So, whatever.php could look something like this: include("header.html"); ?>
include("footer.html"); ?> Play with this a bit and you will get hooked on it. You'll find yourself building pages that are almost all include tags, pulling in info from other php and html source pages. As long as you use the .php extension you can use the php include tags. Otherwise, it can all be html code. Keep in mind, you have to test these php pages online, unless you have PHP on your home system. |
Thanks for the useful info Useless Warrior
i will try out that one. Stein |
while useless warrior's way is certainly easy, mod_layout is the easiest of all ways to go because you don't have to alter your page code at all.
http://tangent.org/index.pl?lastnode_id=478&node_id=362 just have your admin add the module to your apache, it's generally not there by default. -jason |
There are many ways to do it.
If you are using php (ie., php extensions or html is configured to be parse by php) you could use the following in an htaccess. php_value auto_prepend_file "/path/to/header.php"; php_value auto_append_file "/path/to/footer.php"; That will put those files at the top and bottom of each php file or any file configured to be parsed by php. If you are looking for other ways, SSI might be an option for you otherwise you would need some scripting experience or one of the apache modules these other fine folks talked about. Andy |
All times are GMT -4. The time now is 07:11 PM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc