Server side includes (SSI) allow you to add lots of dynamic content to your pages. They enable you to gather lots of information without the need for client side scripting (eg.javascript) . You can insert the date and time into all of your pages, detect which browser is being used and a whole lot more.
I think one of the best uses for SSI has to be website maintenance. Imagine this scenario, you have a website which has 5 pages. You have a navigation bar on all pages which link all the pages together. Let's say you have to change the text for one of the links. Here's a quick breakdown of what you would have to do :
Imagine if you had 50 or even 500 pages on your site!
Wouldn't it be nice if your navigation was only one text file that was included into your page wherever you wanted it to go. Welcome to server side includes.
First you have to check that your server is SSI enabled. Create a simple page.
For example :Save the file as date.shtml , upload it to your site and view it in your browser. If you see something like Monday, 07-Oct-2024 05:15:23 BST then you are ready to rock , if you don't see anything then contact your hosting provider and ask them to enable SSI.
a 5 page example
For this demo you will need to create and save 6 pages.
Then create this page and save it as
navigation.inc
What happens when the server gets a request for a .shtml file is this - the server looks at the file for special commands (the line in red). In this example we want it to include a file called navigation.inc. The contents of navigation.inc are compiled into the page that the server will eventually send to the visitor.
If you view the source of the page from your browser, you should see something like this.
This is only a small example of the power of server side includes and I hope that this small tutorial has made you want to learn more :) and believe me, there is a lot more to learn.