Website Plan
admin | IMS28 Apr 2010
In few of the website posts some weeks back, I told I would like to make common header, footer and sidebar which would make things much more easier to maintain. I decided to do the code for it.
I decided to use Apache RewriteRule. My .htaccess file looks like:
RewriteEngine On
RewriteRule ^(.*).html$ index.php?paget=$1
What it does is any requested file over the http port, let’s say contact.html would execute the php index.php?paget=contact
What my php had to do is parse it, and have common elements of sidebar, footer, and header.
include_once "header.html";
if(file_exists("page_{$_GET['paget']}.html") || ($_GET['paget'] == ''))
{
if($_GET['paget'] == '')
{
include_once "page_index.html";
}
else
{
include_once "page_{$_GET['paget']}.html";
}
}
else
{
include_once "page_404.html";
}
include_once "sidebar.html";
include_once "footer.html";
My php takes care of the input, and first prints header, then the specific page_request.html page in this case page_contact.html, then sidebar.html and then footer.html. I didn’t have time to implement it completely so I just left it at that. But I tested the code, and it works