Solved

Add footer to all pages using .htaccess?

Posted on 2006-11-25
3
522 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
3 Comments
 
LVL 8

Accepted Solution

by:
jk2001 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now