-
Using Basic Server Side Includes (SSI)
Server side includes are what their name sounds like. A way to include the contents of another file into your current web page BEFORE the web page gets sent off to the surfer. Not only does this include contents of a static file but you can also include the results of a CGI program and on some web servers, you can even have it display the current date and time.
Now, many web hosts do not normally have server side includes turned on. You will have to ask your host if they have SSI turned on and if they do, what is the file name extension for SSI. By default, SSI files have an .shtml extension.
Sometimes, you can turn SSI on yourself. If you host doesn’t have SSI turned on for you already, you can try adding the following two lines to your .htaccess file. Then create a file with the .shtml extension, include a SSI command and see if it works.
AddType text/html .shtml
AddHandler server-parsed .shtmlWhen you use SSI commands, you place them exactly in the location within your web page where you want the output of the SSI command to appear when you finally browse the page. If you have SSI, then you can use the following command to include a file. When you include a file, you can either give it a path name to the file or you can give a URL to the file. I’ll list both here.
<!–#include file=”/some/path/above/my/web/to/my/header.html” –>
This is an example of how to include a file based on its path name. Now,
here’s the same file put included with its URL.<!–#include virtual=”/to/my/header.html” –>
And this is an example of how to use a URL. With a URL however, it cannot be a complete URL such as http://www.somesite.com/somefile.html. It has to be within your current website. You can also use the URL method to run a CGI script! Here’s an example of that:
<!–#include virtual=”/cgi-bin/somescript.cgi?myfirstarg=1amp;mysecondarg=2″
–>As you can see, we can even pass arguments to the CGI script just as if you typed it into your browser! There is also another way of running a CGI script but this is not as widely used any more and you should use the #include virtual method instead. Here is the same example so that you will know what it means when you see it.
<!-exec cgi=”/cgi-bin/somescript.cgi?myfirstarg=1amp;mysecondarg=2″ –>
As I mentioned earlier, you can use SSI to display the current time and date. Here’s how:
<!-echo “$DATE_LOCAL” –>
This will display the current date and time. SSI is usually used when you want to have a standard header or footer on each page. It’s also used for displaying rotating banners or page counters. As you see above, you can also use it to display the current date and time or the date when the page was last modified.
SSI has also been used for cloaking and some tracking software uses SSI to track each incoming hit to the web page. If you would like more information about SSI, go to
http://www.apache.org/docs/mod/mod_include.html. This is the definitive guide on SSI on the Apache web server.Most other web servers that use SSI also follow these conventions.
Article written by Lee
Leave a Reply
Related Posts
Recent Posts
- Why Cant I Get Indexed By The Search Engines?
- Whats A Twink
- What’s In A Niche?
- What’s A CHMOD?
- What On Earth Is CGI?
- What Is The Golden Ratio?
- What Happens Your Current Processor Bails?
- SMS Marketing To MMS Marketing – WAP Billing Solutions
- AVS Changes – Is The Proverbial Sky Falling?
- Utilizing All The Content You Use On TGP Galleries!