Home Tutorial Php Phpbasics Setting Up SSI on WAMP

 
 

Share on Google+Share on Google+
Setting Up SSI on WAMP
Posted on: April 1, 2010 at 12:00 AM
Advertisement
In this technology we will study about how to set up SSI on WAMP. The Server Side Includes is a simple interpreted server side scripting used in HTML pages to make it more responsive web pages on web server. It is used in big websites which most parts are repetitive.

Setting up SSI on WAMP Server

 

Server Side Includes (SSI) - Definition

The Server Side Includes is a simple interpreted server side scripting used in HTML pages to make it more responsive web pages on web server. It is used in big websites which most parts are repetitive. SSI enables the HTML pages to add one or more files into a web page and come out with given directives. The SSI makes easy to maintain the site. For instance: If any website have numerous HTML pages with dynamic contents and each time only contents need to be change, the SSI works here. It has some commonly used code that can be reused myriad time in a website.

When a SSI file is parsed in the server, the server takes the entire content of the file and inserts it into the page, replacing the include code. In other word, you can say that SSI are directive that let?s you add dynamically generated content to an existing HTML page, without having to serve the entire page via a CGI program, or other dynamic technology.

How it works:

The SSI works as cut and paste editor for HTML pages. When it is used, the server reads the document and parses it for directives. After that it follows the given instructions and finished with manipulation and come onto the browser.

The SSI-enable HTML files have special extensions but by default it is .shtml, .shtm, or .stm. The HTTP server only recognize those documents with containing appropriate extensions. SSI files support only .ASP, .shtml, .PHP extension and can be included only in them. Similar, all the web servers do not support SSI, except few including Apache web server.

To apply SSI code in SSI supportive web page, you just need to add the following code:

<!--#include virtual="../quote.txt" -->

This code will work for all pages and they will display the latest daily quote.

For example:

SHTML or ASP: <!--#include virtual="/path_relative_to_site" -->

PHP: <?php include("../path_relative_to_document") ?>

The above code will work as a SSI enable web page and return with the given direction on the browser.

Configuring Your Server to permit SSI

Permitting SSI on your server, there is a need to have mod_include installed and enabled. Give the following direction in your httpd.conf file, or in a .htaccess file:

Options +Includes

This instruction informs Apache for asking permission to be parsed for SSI directives. Here, you will have to keep in mind that you will have to give the clear instruction to Apache to parse any specific file. There are two ways to do this:

Instruct the Apache to parse any file with a particular file extension, such as. shtml, with the following directives:

AddType text/html .shtml

AddHandler server-parsed .shtml

However, there is one disadvantage to this approach, if you want to add SSI directives to an existing page, you will have to change the name of that page, and all links to that page, to facilitate .shtml extension, so that those directives can be executed.

The second method is to use the XBitHack directive:

XBitHack on

XBitHack instruct Apache to parse only those files that contain execute bit set files for SSI directives. So, to add SSI directives to an existing page without changing the name of the file, use the following command.

chmod +x pagename.html

This will change the mode of any executable file.

By default Apache does not recognize the last modified plans so it fails to send those. To remove this problem, we can use the XbitHack directive that will tell the Apache to recognize the file from the date of origin rather than the last modification.

How to add SSI (Serverside include support in WAMP)?

Open http.conf file from <your drive):\wamp\bin\apache\Apache2.2.11\conf (e.g. C:\wamp\bin\apache\Apache2.2.11\conf)

Then add the following code:

AddType text/html .shtml

Options +Includes

AddOutputFilter INCLUDES .shtml

The above code should be above "<Directory />" in httpd.conf file

Then find "Options Indexes FollowSymLinks" and replace it with:

Options +Indexes +FollowSymLinks +Includes

Restart wamp and enjoy.



Advertisement

Related Tags for Setting Up SSI on WAMP:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 1, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com