Server Side Includes (SSI)

From ICT science
(Redirected from SSI)
Jump to navigation Jump to search

Server Side Includes (SSI) allow the inclusion of files into your web pages. More information on SSI can be found on the Apache documentation pages.

SSI may be used on web pages ending with .shtml; however, you may wish to extend the functionality to other pages.

Problems with migrated pages

Under the current web server configuration, the use of SSI has been restricted to .shtml pages only. If you have been using SSI in other pages, e.g. .html files, these will no longer function. There are three ways of solving this problem.

Solution: renaming your files

Simply renaming the files that contain SSI to .shtml will resolve the issue. So mypage.html should become mypage.shtml.

However, this may introduce other problems, especially when you have (external) links to these pages.

Solution: re-activating SSI for .html files

You can also configure your own web site such that it will recognize SSI within other files. For this you will need a .htaccess file. The .htaccess file is a plain text file that should be placed in the www directory, or in any directory/directories that contain(s) SSI files.

The .htaccess file should contain at least the following line:

AddOutputFilter INCLUDES .html

Any .html files in the directory that contains the .htaccess (or in any subdirectories) will be scanned for SSI.

Solution: activating SSI for any file type

If you want even more possibilities, you can activate SSI for any file, including SSI files themselves.

Please be aware that for this method to work, you will need to login on the linux interactive shell. If you do not know how to do this, or how to use the chmod command, you should refrain from using this method.

For this you will need a .htaccess file and the chmod command.

The .htaccess file is a plain text file that should be placed in the www directory, or in any directory/directories that contain(s) SSI files.

Login on the linux interactive shell and change directory to the directory where you want SSI te work. A .htaccess file should be placed in this directory, and it should contain at least the following line:

XBitHack on

Next, you should set the execute bit for any file that is to be parsed for SSI, using the chmod command:

chmod u+x <filename>

where <filename> is the name of the file that should be parsed for SSI. Wildcards or multiple file names are allowed, but you should restrict this method to files that actually contain SSI.

You can use this method to nest include files: simply set the execute bit for the SSI that contains includes.

See also