Solved

Add footer to all pages using .htaccess?

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
linux pull logs and export FTP 4 60
AWS CLI - Instances, Volumes & Tagging 2 75
i can not do linux commands in cygwin windows 10 6 62
how to rebuild XFS volume from LV 19 38
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

895 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

13 Experts available now in Live!

Get 1:1 Help Now