Server Side Includes (SSI) are directives that allow information to be added to a web page before they are viewed. For the official document on SSI, click here (A tutorial can be found here).
To enable SSI processing on a web page, change its extender from ".html" to ".shtml".
Here are some examples of SSI directives:
Please note: for security reasons, use of the "#exec" directive is restricted, and it will not work from personal web page sites.
Example:
<PRE> <!--#exec cmd="ls -lts /usr/local/info/sens/services/webhosting/advanced" --> </PRE>
Output:
Example:
<!--#config errmsg="BAD CODE, DUDE! BAD CODE!! " --> <!--#exce cgi="/cgi-bin/fortune" --> <!-- ^^ typo here -->
Output:
BAD CODE, DUDE! BAD CODE!!
Example:
<PRE> <!--#include virtual="sample.txt" --> </PRE>
Output:
This is a simple text file for demonstrating SSI capabilities.
Example:
<!--#config timefmt="%l:%M:%S %p %Z %d %B %Y" --> <!--#echo var="DATE_LOCAL" -->
Output:
10:40:23 AM EDT 28 August 2008
Example:
<!--#config timefmt="%T %d %B %Y GMT" --> <!--#echo var="DATE_GMT" -->
Output:
14:40:23 28 August 2008 GMT
Example:
<!--#config timefmt="%B %d, %Y" --> Last modified: <!--#echo var="LAST_MODIFIED" -->
Output:
Last modified: August 25, 2007
Example:
<!--#echo var="DOCUMENT_NAME" -->
Output:
ssi.shtml
Example:
<!--#echo var="DOCUMENT_URI" -->
Output:
/services/webhosting/advanced/ssi.shtml
Example:
<!--#config sizefmt="bytes" --> File Size: <!--#fsize virtual="sample.txt" --> bytes. <P> <!--#config sizefmt="abbrev" --> File Size: <!--#fsize virtual="sample.txt" -->
Output:
File Size: 63 bytes.
File Size: 1k
Example:
File Last Modified: <!--#flastmod virtual="sample.txt" -->
Output:
File Last Modified: October 29, 2002
Example:
<!--#printenv -->
Output:
DOCUMENT_ROOT=/usr/local/info/sens HTTP_ACCEPT=Accept: application/xhtml+xml,text/html;q=0.9,text/plain; HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7 HTTP_ACCEPT_ENCODING=gzip HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5 HTTP_CACHE_CONTROL=no-cache HTTP_CONNECTION=close HTTP_HOST=www.sens.buffalo.edu HTTP_PRAGMA=no-cache HTTP_USER_AGENT=CCBot/1.0 (+http://www.commoncrawl.org/bot.html) PATH=/usr/bin:/sbin:/usr/sbin:/usr/ucb:/usr/ccs/bin:/eng/admin/bin:/usr/local/bin REMOTE_ADDR=38.103.63.59 REMOTE_PORT=54592 SCRIPT_FILENAME=/usr/local/info/sens/services/webhosting/advanced/ssi.shtml SERVER_ADDR=128.205.25.122 SERVER_ADMIN=wwwadmin@eng.buffalo.edu SERVER_NAME=www.sens.buffalo.edu SERVER_PORT=80 SERVER_SIGNATURE=<ADDRESS>Apache/1.3.36 Server at www.sens.buffalo.edu Port 80</ADDRESS> SERVER_SOFTWARE=Apache/1.3.36 (Unix) mod_jk/1.2.23 PHP/5.2.3 mod_perl/1.29 UNIQUE_ID=SLa414DNGQcAAFXNWyQ GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 REQUEST_METHOD=GET QUERY_STRING= REQUEST_URI=/services/webhosting/advanced/ssi.shtml SCRIPT_NAME=/services/webhosting/advanced/ssi.shtml DATE_LOCAL=August 28, 2008 DATE_GMT=August 28, 2008 LAST_MODIFIED=August 25, 2007 DOCUMENT_URI=/services/webhosting/advanced/ssi.shtml DOCUMENT_PATH_INFO= USER_NAME=yearke DOCUMENT_NAME=ssi.shtml