Quick Links: Overview | Configuring SSI in Apache | SSI Directives Cheatsheet
SSI Directives: Overview
- The SSI statement must be within the text of a web page.
- An SSI looks a bit like an HTML comment:
<!--#element attribute=value attribute=value ... -->
- The web server must support SSI (Apache and IIS both do, to one extent or another)
- Enabling server side includes increases the potential for security breaches on the server.
- The web server must be configured to allow server side directives to run
- The web server must be configured to recoginze a specific document type or extension (*.shtm, or *.shtml)
Enabling Server Side Includes (SSI) in Apache:
- Open the httpd.conf file, or create/edit the .htaccess in the directory where want want to enable Server Side Includes (SSI).
- Add the following server configuration directive:
Options +Includes
Options IncludesNOEXEC
- Define a file type that will contain directives to reduce server workload:
AddType text/html .shtm
AddOutputFilter INCLUDES .shtm
- Rename existing files to have a .shtm file extension (or whatever extension you used).
- If you used a .htaccess file, be sure to reset the file permissions after editing it so that it is non-writeable again. A world-writeable .htaccess file is a security risk.
SSI Directives Cheatsheet
| CONFIG DIRECTIVE | |
|---|---|
| <!--#config errmsg="Message Text"--> | |
| <!--#config sizefmt="bytes"--> | |
| <!--#fsize file="cheatsheet.shtml"--> | 18,934 bytes |
| <!--#flastmod file="cheatsheet.shtml"--> <!--#flastmod virtual="cheatsheet.shtml"--> |
Saturday, 19-May-2018 15:41:17 MDT bytes Saturday, 19-May-2018 15:41:17 MDT bytes |
| ECHO DIRECTIVE <!--#echo var="[SSI KEYWORD]"--> | |
|---|---|
| The Echo directive can print into the page any of the server environment variables, or the CGI environment variables into the page. | |
| SERVER-RELATED VARIABLES | |
| Keyword | Value Returned by Server |
| DATE_GMT | Friday, 05-Dec-2025 09:59:28 GMT |
| DATE_LOCAL | Friday, 05-Dec-2025 02:59:28 MST |
| SERVER_NAME | inetdaemon.com |
| SERVER_SOFTWARE | Apache |
| SERVER_PROTOCOL | HTTP/2.0 |
| SERVER_PORT | 443 |
| GATEWAY_INTERFACE | CGI/1.1 |
| REQUEST_METHOD | GET |
| CLIENT-RELATED VARIABLES | |
|---|---|
| Keyword | Value Returned by Server |
| REMOTE_HOST | (none) |
| REMOTE_USER | (none) |
| REMOTE_ADDR | 216.73.216.99 |
| REMOTE_IDENT | (none) |
| HTTP_ACCEPT | */* |
| HTTP_REFERRER | (none) |
| HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) |
| DOCUMENT-RELATED VARIABLES | |
|---|---|
| Keyword | Value Returned by Server |
| CONTENT_TYPE | (none) |
| CONTENT_LENGTH | (none) |
| DOCUMENT_NAME | cheatsheet.shtml |
| DOCUMENT_ROOT | /home4/inetdaem/public_html |
| DOCUMENT_URI | /tutorials/www/web_server/cgi/ssi/cheatsheet.shtml |
| PATH_INFO | (none) |
| PATH_TRANSLATED | (none) |
| QUERY_STRING | |
| SCRIPT_NAME | /tutorials/www/web_server/cgi/ssi/cheatsheet.shtml |
Bookmark this page and SHARE: