|
|
||||
When implemented, SSI can be a real time saver. For example, every document in this support section uses the SSI command include to insert the header images and links (header_support.html). By doing this, any changes that need to be made to the header will be made to one file instead of all of the files in the support area. The value of SSI is apparent in situations such as this.
The first rule of using SSI is that any page containing commands should be named .shtml, .shtm or .sht. By changing the extension, you're letting the webserver know that those files must be parsed before sending them to the client.
The next thing to remember is that all SSI commands must use the following format:
<!--#include virtual="/dir/file.ext"-->
The tag used for SSI is similar to the HTML comment tag which looks like this:
<!-- Comment Tag -->
Config - Echo - Exec - Flastmod - Fsize - Include
[an error occurred while processing this directive]
You can modify this to display whatever you'd like, for instance <!--#config errmsg="SSI Error, time for a nap!" --> will return:
SSI Error, time for a nap!
This page is 16K
However, by using the bytes variable like this: This page is <!--#config sizefmt="bytes"--><!--#fsize file="SSI_Server_Side_Includes.shtml"--> ,you can change the display to:
This page is 16,780
There is one more variable for sizefmt, abbrev. This page is <!--#config sizefmt="abbrev"--><!--#fsize file="SSI_Server_Side_Includes.shtml"--> will provide an output like this:
This page is 16K
Depending on how your webserver displays file sizes by default, you may
or may not need to use abbrev.
Wednesday, 20-Aug-2008 00:44:18 GMT
To change the above to this:
August 20, 2008
You use this tag <!--#config timefmt="%B %d, %Y" --> in conjunction with the tag that displays the actual date, <!--#echo var="DATE_LOCAL" -->.
For more information on time format commands, check out the SSI Time Format Chart.
It's now Wednesday, 20-Aug-2008 00:44:18 GMT
It's now Wednesday, 20-Aug-2008 00:44:18 GMT
You're using CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
This page last updated Saturday, 7-Jan-2006 18:07:20 GMT
This tag works much like flastmod, which is discussed below.
http://www.internetconnection.net/signup.shtml?Domain-Name
Perhaps one of the best uses for <!--#echo var="QUERY_STRING" --> is in conjuction with a form.
For example, using Internet Connection's SSL server, you can specify certain form fields to be required. When you do this it is recommended that you specify a "form failure" page to inform your visitors that their form was missing some required information. This "form failure" page could utilize <!--#echo var="QUERY_STRING" --> so that the name of the required form field could be displayed. For more on this, please check out Internet Connection's Secure Sockets Layer (SSL) support document.
*The output of these commands can be altered with the timefmt variable of the SSI command config.
#!/bin/perl
my $agent = $ENV{HTTP_USER_AGENT};
if ($agent =~ /MSIE/) {
print "Content-Type: text/html\n\n";
print "\<span\ class\=\"code\"\>You\'re\ using\
Microsoft\®\;\ Internet\ Explorer\®\;\ 5\.0\<\/span\>\n";
} else {
print "Content-Type: text/html\n\n";
print "\<span\ class\=\"code\"\>You\'re\
not\ using\ Microsoft\®\;\ Internet\ Explorer\®\;\ 5\.0\<\/span\>\n";
}
exit 0;
This script is called with this tag <!--#exec cgi="exec-test.cgi" --> and the actual text output appears as such:
You're not using Microsoft® Internet Explorer® 5.0
This page last updated Saturday, 7-Jan-2006 18:07:20 GMT
However, flastmod and echo differ in that flastmod allows you to specify the following two attributes. These attributes may be used to display the "last modified" date of other files on the server. This would be valuable in a number of situations, for example if you were creating a site map and wanted to list the date that each file had last been updated.
The support section's main page was last modified Friday, 24-Jun-2005 19:23:04 GMT
You cannot use /, ../ etc. with this attribute.
Internet Connection's home page was last modified Friday, 24-Jun-2005 19:23:04 GMT
The output of this command can be altered with the timefmt variable of the SSI command config.
This page is 16K
The output of this command can be altered with the sizefmt variable of the SSI command config.
Monkey's are cute. Monkey's have opposable thumbs.
Like the flastmod command, include has two variables that can be used for added flexibility:
Llamas smell strange. Yes they do!
Related Items