Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   How to add header and footer with .htaccess (http://www.greenguysboard.com/board/showthread.php?t=8604)

sttvsttv 2004-06-23 07:54 AM

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

Cleo 2004-06-23 08:18 AM

I use php or ssi to add headers and footers not htaccess.

swedguy 2004-06-23 12:27 PM

The Apache module is called mod_layout.

Cleo 2004-06-23 12:33 PM

That is what I love about this business, always something new to learn. :)

sttvsttv 2004-06-23 01:19 PM

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

Useless 2004-06-25 11:06 PM

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");
?>
All the wacky porn shit you want on your page.

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.

sttvsttv 2004-06-26 02:37 AM

Thanks for the useful info Useless Warrior


i will try out that one.

Stein

Jason 2004-06-27 01:55 PM

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

AcidMaX 2004-06-28 10:12 AM

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