My Web Hosting Manual


Home > .htaccess > Enable SSI with .htaccess

Enable SSI with .htaccess

There are quite a few functions you can enable by adding SSI to your server.

Usually you have to use .shtml to enable these functions. This activates the posibility to include a file in another, banners, and some other functios.

Before I started using a CMS, and sometimes even now too, I used SSI to be able to include a file within another. Huh? Imagine you create a website with 100 pages. Imagine you misspelled something in your header or wish to change your logo dimensions. With SSI you can create 1 file with only your header information and have that file included in all documents. This way, if you need to change it the header, you don't have to change 100 .html files, but just 1.

Same applies to footer and menus.

Say you have a really cool menu. Its on every page of course. Suddenly you want to add an option to that menu. Do you have to go and change every page in your site? Not any more. Have just one file with that cool menu and have it included in all pages. This way you just modify one menu.html file and all pages change automaticly.

So how does it work? First lets activate SSI adding the following line to your .htaccess like this:

AddHandler server-parsed .html

As an option, you may add the other common file types:

AddHandler server-parsed .html
AddHandler server-parsed .shtml
AddHandler server-parsed .htm

The above lines tell the Apache Web Server to allow "Server Side Includes" in documents with the file extension '.html', '.shtml' and '.htm'.

Cool. Now what? Now you should "include" the file or information you want to include. These are two samples on how to do it:

<!--#exec cgi="/cgi-bin/banner/script.cgi"-->

The above line would execute your cgi script located in your cgi-bin directory and show the result output on the page as if it were one more element.

<!--#include virtual="/directory/document.html"-->

The above sample includes the file named document.html located in directory called /directory/ into the current page.

May not be http://www.domain.com/directory/document.html.

Review It

You might also be interested in:






Top Hosting
  - Host Gator
  - Host Monster
  - Blue Host
  - Easy CGI
  - Lunar Pages
       
All content has been created by Juan Carlos Gorospe. These are my opinions and experiences.
Copyright © 2008, Juan Carlos Gorospe. All Rights Reserved.