22i design - web design Farnborough

Wednesday, November 13, 2019



This page uses Valid CSS
Valid HTML 4.01!
For what it's worth, 22i design is a member of the UKWDA
Get FireFox - The Browser ReLoaded



22i DESiGN » WEB DESiGN TiPS » SERVER SiDE iNCLUDES

Server Side Includes

Server Side Includes are a simple way of distributing common content across a website. Take, for instance, a menu system. If you run a site with X amount of HTML pages then you would normally have to change X pages of code in which the menu system is used. It's OK if you can do a global find & replace, but by using server side includes you can change one menu in many pages by changing one file.

Getting Started with Server Side Includes

So, you have a menu system in your HTML pages. If you were organised when you built the site it's either in a table or a div, nice and tidy and easy to isolate, copy & paste, right?

Grab the menu system source code by copy & pasting it into a new file. The code can go into the new file by itself without any html, head, title or body tags. Save this file to an appropriate place on your server; you could create a folder called /ssi in the root of your server and save it there as, say, menu.html

In your page, where you removed the menu from, replace the "gap" with the code

For PHP

<?php
include ("http://www.yourdomain.com/ssi/menu.html");
?>

If you aren't using PHP then another method is to save your menu system as a file named menu.inc, again save it in the /ssi folder. Remember to change the extension to .inc

Normally you would have to call the include in through an SHTML page, basically a page with the .shtml extension. However, you can configure your server to read .htm or .html files and deliver server side includes.

<!--#include virtual="/ssi/menu.inc" -->