Solved

Add footer to all pages using .htaccess?

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
expand ext4 on centos 6 5 69
How to setup virtualization in Redhat? 4 39
Windows 10 linux VM 30 91
php mail() send emails but the message is lost 4 33
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

737 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