SSI Technology-shtml Interpretation (generate static when the most fire) _ Application techniques

Source: Internet
Author: User
Tags echo command php script
What is shtml shtml grammar shtml tutorial format writing technique
Using SSI (Server Side Include) technology
It's so hard to find creative graphic designers and people with experience in scripting. And if a single page is a PHP script site, will create a very large page maintenance difficulties. And the use of the automatic addition of PHP and the end of the method, so that almost all the pages are semantically incomplete, can not use any of the page design tools to work, is another drawback.
Using SSI technology, HTML Web pages and CGI scripts can be effectively separated, and the repetitive HTML elements can be abstracted and isolated to reduce the maintenance burden.
SSI (server Side Includes) are directives that are into HTML pages, and placed on the server while the pages evaluated B Eing served.  They let your add dynamically generated content to a existing HTML page, without have to serve the entire page via a CGI program, or other dynamic technology.
Full:
Configure Apache, support ssi# this tells Apache so you want to permit files to# is parsed for SSI directives. Options +includes
# at Linux or Unix can use# Options +includes-includesnoexec# Win32 It
# you have to tell Apache which files should is parsed. AddType text/html. Shtmladdhandler server-parsed. shtml
SSI syntax
Basic SSI directives Syntax
<!--#element Attribute=value attribute=value ...-->
Today ' s date
<!--#config timefmt= "%y/%m/%d%a%h:%m:%s"-->today is <!--#echo var= "date_local"-->
Modification date of the file
This document is last modified <!--#flastmod file= "index.html"-->
Including the results of a CGI program
<!--#include virtual= "/cgi-bin/counter.pl"--><!--#include virtual= "/cgi-bin/example.cgi?argument=value" -->
can use "#exec cgi=" directive, but it can be disabled using the IncludesNOEXEC Option.
Including a standard footer
<!--#include virtual= "/footer.html"-->
Executing commands
<!--#exec cmd= "ls"-->
This feature is dangerous. You can allow SSI, but not the exec feature and the includesnoexec argument to the Options directive.
Setting variables
<!--#set var= "modified" value= "$LAST _modified"--><!--#set var= "date" value= "${date_local}_${date_gmt}"- >
Conditional expressions
<!--#if expr= "test_condition"--><!--#elif expr= "test_condition"--><!--#else--><!--#endif >
1. config command
The config command is primarily used to modify the default settings for SSI. which
ErrMsg: Sets the default error message. In order to return the user-defined error message normally, the errmsg parameter must be placed in front of the other SSI commands in the HTML file, otherwise the client can only display the default error message, not the custom information set by the user.
<!--#config errmsg= "error! Please email webmaster@mydomain.com-->
TIMEFMT: Defines the use format for dates and times. The TIMEFMT parameter must be used before the echo command.
<!--#config timefmt= "%A,%B%d,%Y"-->
<!--#echo var= "last_modified"-->
Display results as:
Wednesday, April 12, 2000
Perhaps the user is unfamiliar with the%a%B%d used in the previous example, so let's summarize some of the more commonly used date and time formats in SSI in tabular form. www.domain.com
SIZEFMT: Determines whether the file size is expressed in bytes, kilobytes, or megabytes. If the parameter value is "bytes" in bytes, the abbreviation can be used for kilobytes and megabytes. Similarly, the SIZEFMT parameter must be placed in front of the fsize command before it can be used.
<!--#config sizefmt= "bytes"-->
<!--#fsize file= "index.html"-->
2. Include command
The Include command inserts text or pictures from other documents into the currently parsed document, which is the key to the entire SSI. You can update the entire site in an instant by simply changing one file with the Include command!
The include command has two different parameters:
Virtual: gives a dummy path to a document on the server side. For example:
<!--#include virtual= "/includes/header.html"-->
File: Gives the relative path to the current directory, where you cannot use the. /"And you cannot use absolute paths. For example:
<!--#include file= "header.html"-->
This requires a header.html file to be included in each directory.
3. Echo command
The echo command can display the following environment variables:
Document_name: Displays the name of the current document.
<!--#echo var= "Document_name"-->
Display results as:
Index.html
Document_uri: Displays the virtual path of the current document. For example:
<!--#echo var= "Document_uri"-->
Display results as:
/yourdirectory/yourfilename.html
With the development of the Web site, the increasingly long URL address will certainly make people headache. If you use SSI, everything will be solved.
Another tutorial on SSI technology in Apache can be found in:
Apache Guide: Server-side include getting Started
Http://www.kreny.com/doc/apache2.0/howto/ssi.html
Reference Web page
Http://www.worldhello.net/doc/website_howto/ssi.html
Http://www.carleton.ca/~dmcfet/html/ssi.html
http://www.dizign.de/ssi/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.