Server Side Includes

  • Slushie
  • Beginner
  • Beginner
  • Slushie
  • Posts: 38

Post 3+ Months Ago

I want to do my website using Server Side Includes, so that I won't have to redo every single page when I want to add something to the navigation bar. I don't really know what to do. If someone can explain to me exactly what to do, it would REALLY help me out. My Host has this to say about Server Side Includes.

SSI stands for Server Side Include... and it means that you can insert the contents of another web page, program or file into the web page that adds the Server Side Include.

A couple of important points you need to follow for SSI to work on your domain.
1. The web page that adds the SSI instruction to include another page or program MUST end with .shtml or .sht rather than .html or .htm.
2. The URL to the page you want to insert must be relative to the current web page rather than a full URL.
The SSI feature on your domain is limited to what is known as a "exec cgi command". This simply means that you can insert into any page the ability to execute any cgi program. The format for a Server Side Include is:

<!--#element attribute=value -->

or

<!--#include virtual="colors.ssi" -->
<!-- This command inserts the content of the file colors.ssi -->
<!-- colors.ssi must be in same directory as this file -->

One quick observation... do you notice how this SSI instruction uses a *relative* URL (/cgi-bin/....) instead of a FULL URL? This is very important to keep in mind when using SSI.

For example, let's say we want to include a counter program (that has the name, counter.cgi) on our home page, called normally index.html. Remember! Because we want to add a SSI instruction in our home page, it must end with .shtml or .sht. In this case, we would name it index.shtml.


I was wondering what exactly am I supposed to do, do I insert an HTML code in my webpage where I want the navigation bar to be placed? What do I enter in? I need to be able to to this, because I am planning on having a right Side bar that I can change every day. If anyone can help me with this, it would be an amazing help. I use Frontpage if this means anything.
  • monoheinz
  • Student
  • Student
  • User avatar
  • Posts: 79
  • Loc: Norway

Post 3+ Months Ago

Long time since I've used ssi, but there isn't really very much to it.
Let's say you've got the html of the side bar stored in a file called sidebar.inc. To include this file in your main documents you must use the ssi command <!--#include virtual="sidebar.inc" --> wherever you want the bar to appear.
Note that sidebar.inc should not have html tags such as <body>, <html> etc, as the the file will be merged into the main documents by the server. The web browser will never know what happened :)
  • Slushie
  • Beginner
  • Beginner
  • Slushie
  • Posts: 38

Post 3+ Months Ago

I kind of understand. So I would make my sidebar in something like notepad, save it as a .txt file or should it be inc. But it shouldn't have <body>, and <html>.
How do I include the ssi command <!--#include virtual="sidebar.inc" --> ?
Do I insert it as a HTML Code in Frontpage, or do I just enter those letters?
  • Slushie
  • Beginner
  • Beginner
  • Slushie
  • Posts: 38

Post 3+ Months Ago

YES!!! I finally did it :)

Thanks for the help, this helps me out alot.
  • monoheinz
  • Student
  • Student
  • User avatar
  • Posts: 79
  • Loc: Norway

Post 3+ Months Ago

The file ending is up totally up to you. .txt works fine too, as long as you refer to sidebar.txt. The ssi command must be inserted in the code view in Frontpage. And be aware that ssi won't work locally on your computer - it must be parsed by a server. So you have to upload the files and view the site on the internet to see the result.

Edit: You beat me there :) Glad you figured it out!
  • Slushie
  • Beginner
  • Beginner
  • Slushie
  • Posts: 38

Post 3+ Months Ago

That was the part I made my big mistake on, I didn't know I had to upload to my server. Thanks for the help again.
  • russ1162
  • Born
  • Born
  • russ1162
  • Posts: 3

Post 3+ Months Ago

how do you view SSI file offline ?
  • monoheinz
  • Student
  • Student
  • User avatar
  • Posts: 79
  • Loc: Norway

Post 3+ Months Ago

You will have to install a local web server with SSI, and parse the pages with it (like http://localhost/whatever.ssi).
First of all you can download Foxserv (http://sourceforge.net/projects/foxserv/) which is a full server package (Apache, php and mySql).
Further, this guide might tell you how to configure the server to use SSI.

Good luck
  • russ1162
  • Born
  • Born
  • russ1162
  • Posts: 3

Post 3+ Months Ago

with out install a local web server with SSI how could i view ssi files offline? :?:

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.