Quick Links: Overview | Configuring SSI in Apache | SSI Directives Cheatsheet

SSI Directives: Overview

  1. The SSI statement must be within the text of a web page.
  2. An SSI looks a bit like an HTML comment:

     

    <!--#element attribute=value attribute=value ... -->

     

  3. The web server must support SSI (Apache and IIS both do, to one extent or another)
  4. Enabling server side includes increases the potential for security breaches on the server.
  5. The web server must be configured to allow server side directives to run
  6. The web server must be configured to recoginze a specific document type or extension (*.shtm, or *.shtml)

Enabling Server Side Includes (SSI) in Apache:

  1. Open the httpd.conf file, or create/edit the .htaccess in the directory where want want to enable Server Side Includes (SSI).
  2. Add the following server configuration directive:

     

    Options +Includes

    Options IncludesNOEXEC


  3. Define a file type that will contain directives to reduce server workload:

     

    AddType text/html .shtm

    AddOutputFilter INCLUDES .shtm


  4. Rename existing files to have a .shtm file extension (or whatever extension you used).
  5. 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, 23-Feb-2013 21:50:38 MST bytes
Saturday, 23-Feb-2013 21:50:38 MST 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
KeywordValue Returned by Server
DATE_GMT Friday, 19-Jan-2018 13:12:00 GMT
DATE_LOCAL Friday, 19-Jan-2018 06:12:00 MST
SERVER_NAME www.inetdaemon.com
SERVER_SOFTWARE Apache
SERVER_PROTOCOL HTTP/1.1
SERVER_PORT 80
GATEWAY_INTERFACE CGI/1.1
REQUEST_METHOD GET

 

CLIENT-RELATED VARIABLES
KeywordValue Returned by Server
REMOTE_HOST (none)
REMOTE_USER (none)
REMOTE_ADDR 172.68.65.233
REMOTE_IDENT (none)
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_REFERRER (none)
HTTP_USER_AGENT CCBot/2.0 (http://commoncrawl.org/faq/)

 

DOCUMENT-RELATED VARIABLES
KeywordValue Returned by Server
CONTENT_TYPE (none)
CONTENT_LENGTH (none)
DOCUMENT_NAME cheatsheet.shtml
DOCUMENT_ROOT /home1/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:  

Search

Donations

Free Training