Solved

Add footer to all pages using .htaccess?

Posted on 2006-11-25
3
545 Views
Last Modified: 2013-12-16
I want to add a footer to all the pages of a site.  I am thinking I could use .htaccess file to do it easily.  I am currently using frames and I want to get away from them.

What do I need to put in the .htaccess file to get it to work?
0
Comment
Question by:GodadoLLC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
John Kawakami earned 500 total points
ID: 18014091
Hmmm.... .htaccess isn't the right way, but there really isn't a real "right way".

The canonical right way is SSI:  http://httpd.apache.org/docs/2.0/howto/ssi.html

That requires you to modify the footer for each file, so it becomes <!--#include virtual="/footer.html"-->

If that's not feasible, second best is to use the mod_rewrite feature to turn URLs into parameters to a script that will add the footer.  In PHP, it would be done like this:

In .htaccess:
RewriteEngine on
RewriteRule /(.*.html)/ /addFooter.php?file=$1 [P]

And addFooter.php would do this:
<?php
echo file_get_contents( $_GET['file'] );
echo "footer";
?>

Sorta -- you have to check the file path to make sure it's legitimate, and that you look for the file from the doc root directory.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question