sHTML Streamlined tutorial lets you know what a Shtml_ basic tutorial

Source: Internet
Author: User
Tags perl script
At present, there are mainly the following types of uses:
1. Display server-side environment variables
2. Insert text content directly into the document
3, display Web documents related information (such as file production date/size, etc.)
4, direct execution of the various programs on the server (such as CGI or other executable programs)
5, set the SSI information display format (such as file production date/size display) Advanced SSI can set variables using the IF condition statement.
What's the use of SSI? The reason to pull to SSI is because of the acronym for Shtml--server-parsed HTML. Contains HTML text with the embedded server side containing the command. The server will read, analyze, and modify the SHTML document completely before being sent to the browser.
sHTML and ASPs have similar, shtml-named files that use some of the SSI directives, like the instructions in ASP, where you can write SSI instructions in shtml files, when clients access these shtml files,
The server side reads and interprets the shtml files and interprets the SSI instructions contained in the sHTML file, such as: You can use SSI directives in shtml files to refer to other HTML files (#include), and the server to the client files, It is explained that the shtml will not have SSI instructions. It implements the HTML does not have the function, is can realize the dynamic
sHTML can be said to be an evolution of HTML. Like Sina's news system is like this, the news content is fixed, but its above advertisement and the menu and so on is uses the #include reference to come in.
At present, there are mainly the following types of uses:
1. Display server-side environment variables < #echo >
2. Insert text content directly into the document < #include >
3, display Web documents related information < #flastmod >< #fsize > (such as file production date/size, etc.)
4, direct execution of various programs on the server < #exec > (such as CGI or other executable programs)
5, set SSI information display format < #config > (such as file production date/size display mode)
The advanced ssi<xssi> can set the variable to use the IF condition statement.

Using SSI
SSI is a set of commands provided for Web servers that are embedded directly in the annotation content of an HTML document. Such as:
< #include file= "info.htm"-->
is an SSI instruction that copies the contents of the "info.htm" to the current page and, when visitors come to browse, sees the contents of the info.htm in the same way as other HTML documents.
Other SSI instructions use the same form as the previous example, see SSI use is only a little bit of code, the use of the form is very simple.
Of course, if the Web server does not support SSI, it simply skips over its content as a comment, and the browser ignores that information.

How do I configure SSI features on my web server?
On some WEB servers (such as IIS 4.0/sambar 4.2), files containing #include directives must use an extension that has been mapped to an SSI interpreter; otherwise, the Web server will not process the SSI directive; By default, the extension. stm,. shtm and. sHTML is mapped to an interpreter (Ssinc.dll).
Apache is based on your settings, modify srm.conf such as:
AddType text/x-server-parsed-html. sHTML will parse SSI directives only for files with the. shtml extension
AddType text/x-server-parsed-html. HTML will parse SSI directives for all HTML documents
Netscape Web servers use Administration server (Management Server) directly to turn on SSI features.
Website using the Mapping tab in the Server Admin program, the extension Add content type is: Wwwserver/html-ssi
The CERN server does not support SSI, and you can use SSI scams to download a Perl script to http://sw.cse.bris.ac.uk/WebTools/fakessi.html to enable your CERN server to have some SSI directives. (Exec directives are not supported.) )

SSI Instruction Basic Format
SSI Instruction Basic Format:
Program code:
<!-– directive name = "Instruction parameter" >
<!-– directive name = "Instruction parameter" >
Such as
Program code:
< #include file= "info.htm"-->
< #include file= "info.htm"-->
Description
1. <!----> is a comment in HTML syntax that is ignored when the Web server does not support SSI.
2. #include is one of the SSI directives.
3. File is an include parameter, info.htm is the parameter value, and the name of the document to be included in this instruction.
Attention:
1. There is no space between the <!--and the # number, only the SSI instruction and the parameters exist between the spaces.
2. The above punctuation = "", one can not be less.
3. SSI directives are case sensitive, so parameters must be lowercase to work.

SSI instructions to use the detailed
#echo Demonstration
Role:
Inserts an environment variable into the page.
Grammar:
Program code:
<!--#echo var= "variable name"-->
<!--#echo var= "variable name"-->

This document name: program code:
<!--#echo var= "Document_name"-->
<!--#echo var= "Document_name"-->
Now Time: Program code:
<!--#echo var= "date_local"-->
<!--#echo var= "date_local"-->
Your IP address is the program code:
<!--#echo var= "REMOTE_ADDR"-->
<!--#echo var= "REMOTE_ADDR"-->
#include demonstration
Role:
Inserts the contents of a text file directly into the document page.
Grammar:
Program code:
< #include file= "file name"-->
< #include virtual= "file name"-->
< #include file= "file name"-->
< #include virtual= "file name"-->
The file file name is a relative path that corresponds to the directory where the document using the #include directive resides. The included file can be in the same level of directory or its subdirectories, but not in the previous level directory. File= "nav_head.htm", such as the nav_head.htm document that represents the current directory.
The virtual file name is the full path to the dummy directory on the Web site. For example, the Nav_head.htm file that represents the Hoyi directory under the root directory of the server document; file= "/hoyi/nav_head.htm"
Parameters:
file specifies the location of the containing file relative to this document
virtual Specifies the location relative to the server document root directory
Attention:
1, the file name must have an extension.
2, the included files can have any file extension, I think the direct use of the HTM extension is most convenient, Microsoft recommended use of the. inc extension (it depends on your hobby).
Example:
Program code:
< #include file= "nav_head.htm"--> inserts a header file into the current page
< #include file= "nav_foot.htm"--> inserts the tail file into the current page
< #include file= "nav_head.htm"--> inserts a header file into the current page
< #include file= "nav_foot.htm"--> inserts the tail file into the current page
#flastmod and #fsize Demonstrations
Role: Date #flastmod file Last updated
Length of #fsize file
Grammar:
Program code:
<!--#flastmod file= "file name"-->
<!--#fsize file= "file name"-->
<!--#flastmod file= "file name"-->
<!--#fsize file= "file name"-->
Parameters:
file specifies the location of the containing file relative to this document, such as Info.txt, which represents the Info.txt document under the current directory
virtual Specifies the location relative to the server document root directory, as/hoyi/info.txt
Attention:
The file name must have an extension.
Example:
Program code:
<!--#flastmod file= "news.htm"-->
<!--#flastmod file= "news.htm"-->
Inserts the latest updated date of the news.htm file in the current directory into the current page
Program code:
<!--#fsize file= "news.htm"-->
<!--#fsize file= "news.htm"-->
News.htm the current directory to the current page of the file size

#exec Demonstration
Role:
Inserts the output of an external program into the page. You can insert a CGI program or the input of a regular application, depending on whether you use the parameter cmd or CGI.
Grammar:
Program code:
<!--#exec cmd= "file name"-->
<!--#exec cgi= "file name"-->
<!--#exec cmd= "file name"-->
<!--#exec cgi= "file name"-->
Parameters:
CMD general application
CGI CGI script program
Example:
Program code:
<!--#exec cmd= "cat/etc/passwd"--> will display the password file
<!--#exec cmd= "dir/b"--> will display a list of files in the current directory
<!--#exec cgi= "/cgi-bin/gb.cgi"--> will execute CGI program gb.cgi.
<!--#exec cgi= "/cgi-bin/access_log.cgi"--> will execute CGI program access_log.cgi.
<!--#exec cmd= "cat/etc/passwd"--> will display the password file
<!--#exec cmd= "dir/b"--> will display a list of files in the current directory
<!--#exec cgi= "/cgi-bin/gb.cgi"--> will execute CGI program gb.cgi.
<!--#exec cgi= "/cgi-bin/access_log.cgi"--> will execute CGI program access_log.cgi.
Attention:
As you can see from the example above, this instruction is quite handy, but there are also security issues.
Prohibited method:
. Apache, delete the "options Includes execcgi" code in access.conf;
. In IIS, to disable the #exec command, you can modify the SSIExecDisable metabase;

#config
Role: Specifies the format for error messages, dates, and file sizes returned to the client browser.
Grammar:
Program code:
<!--#c-->
<!--#c-->
<!--#c-->
<!--#c-->
<!--#c-->
<!--#c-->
Parameters:
ErrMsg Custom SSI Execution error messages can be done for any way you like.
SIZEFMT file size display, default to byte mode ("bytes") can be changed to kilobytes ("abbrev")
TIMEFMT time display mode, the most flexible configuration properties.
Example: Displays the size of a file that does not exist
Program code:
<!--#c-->
<!--#fsize file= "files that do not exist. htm"-->
<!--#c-->
<!--#fsize file= "files that do not exist. htm"-->
Display file size in kilobytes
Program code:
<!--#c-->
<!--#fsizefile = "News.htm"-->
<!--#c-->
<!--#fsizefile = "News.htm"-->
Show time in a specific time format
Program code:
<!--#c-->
<!--#echo var= "date_local"--> show today is the day of the week, a few months, time zone
<!--#c-->
<!--#echo var= "date_local"-->
<!--#c-->
<!--#echo var= "date_local"--> show today is the day of the week, a few months, time zone
<!--#c-->
<!--#echo var= "date_local"-->
Xssi
Xssi (Extended SSI) is a set of advanced SSI instructions that are built into the Apache 1.2 or later Mod-include modules.
The available directives are:
#printenv
#set
#if
#printenv
Role: Displays all environment variables that currently exist in the Web server environment.
Syntax: Program code:
<!--#printenv-->
<!--#printenv-->
Parameters: None
Example:
Program code:
<!--#printenv-->
<!--#printenv-->
#set

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.