Incorrect File Extension

Most apache servers are configured to require .shtml as the extension for all files that use SSI. A different extension is used to reduce the server load. If every file was parsed for SSI the load on the server would go up.

If your site is hosted on a different type of server check with your hosting provider to see if a special extension is required for server side includes.

News Directory in cgi-bin

On some servers files in the cgi-bin directory or any directory under the cgi-bin directory can not be used as includes. You can test this by moving your news directory outside the cgi-bin directory. In other words, on some servers, this works:

 -siteroot
 |
 |
 -cgi-bin
 |   |
 |   |
 |   -coranto
 |
 |
 -news

and this doesn't:

 -siteroot
 |
 |
 -cgi-bin
     |
     |
     -coranto
        |
        |
        -news

File or Directory Permissions Set Wrong

The Coranto installation instructions tell you to set the permissions for the news directory to 777. In addition the files created by the profiles themselves may be required to have at least 755 file permissions to be included using SSI.

See chmod Explained for more information about file and directory permissions.

SSI Command Format

The command to include your news into your web page should look like this:

 <!--#include virtual="news.txt" -->

There are no spaces in this part of the command:

 <!--#include

There is one space between the last double quote and the dashes at the end of the command:

 " -->

Many servers will not recognize the command if the spacing is not correct.

There are some servers that are not configured properly that will not work with the space at the end. Try eliminating it if everything else fails.

include file vs. include virtual

From the Apache docs:

file attribute is a file path, relative to the current directory. That means that it cannot be an absolute file path (starting with /), nor can it contain ../ as part of that path. The virtual attribute is probably more useful, and should specify a URL relative to the document being served. It can start with a /, but must be on the same server as the file being served.

Using .htaccess to enable SSI

On an Apache server whenever there is an .htaccess file in a directory the server looks at the file for directives that modify how the server handles files. These could be changes to the way the server is set up as default or additions. To enable SSI for a directory, if it is not enabled server wide make sure that you have an .htaccess file that includes the following:

AddType text/html .shtml
AddHandler server-parsed .shtml
Options +Includes

This lines tell the server how to handle files with includes.

Remember, the directives that you put into the .htaccess file are used by the server for that directory and all of it's sub-directories.

Server does not allow SSI

Make sure that your server allows server side includes, some free hosting providers do not.

Further Reading

Brief SSI Tutorial
English Wikipedia SSI Entry
Apache SSI Tutorial




Page last modified on February 02, 2009, at 07:20 AM