Solved

Add footer to all pages using .htaccess?

Posted on 2006-11-25
3
529 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

Industry Leaders: 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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 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