sHTML Streamlined Tutorials let you know what is the Shtml_ basic tutorial

Source: Internet
Author: User
Tags netscape web server perl script
At present, there are several uses for the following purposes:
1. Display server-side environment variables
2. Insert text content directly into the document
3. Display Web document related information (such as file date/size, etc.)
4, directly execute various programs on the server (such as CGI or other executable program)
5, set the SSI information display format (such as file date/size display mode) Advanced SSI can set the variable using the IF condition statement.
What's the use of SSI? The reason to pull SSI is due to the acronym shtml--server-parsed HTML. Contains HTML text with embedded server-side contains commands. The server will completely read, parse, and modify the SHTML document before it is passed to the browser.
sHTML and ASP have some similar, in shtml named file, use some SSI's instructions, like the instructions in ASP, you can write SSI instruction in shtml file, when the client accesses these shtml files,
These shtml files are read and interpreted by the server side, and the SSI instructions contained in the sHTML file are interpreted, such as: You can refer to other HTML files (#include) in the shtml file with the SSI directive, and the server sends the files to the client. It is already explained that the shtml will not have SSI instructions. It realizes the function that HTML does not have, can realize the dynamic
sHTML, can be said to be a kind of evolution of HTML. Like Sina's news system is like this, the news content is fixed, but its above ads and menus and so on is quoted in # #.
At present, there are several uses for the following purposes:
1. Display server-side environment variables < #echo >
2. Insert text content directly into the document < #include >
3. Display Web document related information < #flastmod >< #fsize > (such as file date/size etc.)
4. Direct execution of various programs on the server < #exec > (such as CGI or other executable programs)
5, set the SSI information display format < #config > (such as file date/size display mode)
Advanced SSI Variables can be set using the IF condition statement.
 
Using SSI
SSI is a set of commands for a Web server that is embedded directly in the comments of the HTML document. Such as:
< #include file= "info.htm"-
is an SSI directive that copies the contents of the "info.htm" to the current page, and when visitors come to the browser, they see the contents of the info.htm in the same way as other HTML documents.
The other SSI instructions are basically the same as the example just now, it can be seen that SSI uses just inserting 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 treats it as a comment and skips through it, and the browser ignores the 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 extensions that have been mapped to the SSI interpreter; otherwise, the WEB server will not process the SSI directive; By default, the extension. stm,. shtm, and. The shtml is mapped to the Interpreter (Ssinc.dll).
Apache is based on your settings and modifies srm.conf such as:
AddType text/x-server-parsed-html. shtml will only parse the. shtml extension files for SSI instructions
AddType text/x-server-parsed-html. HTML will parse SSI instructions for all HTML documents
The Netscape Web server uses Administration server (Management Server) directly to turn on SSI functionality.
Website using the mapping tag in the server Admin program, the extension adds a content type of: Wwwserver/html-ssi
The CERN server does not support SSI, and with SSI scams, a Perl script can be downloaded to http://sw.cse.bris.ac.uk/WebTools/fakessi.html to allow your CERN server to use some SSI instructions. (Exec directives are not supported.) )
 
SSI Instruction Basic Format
SSI Instruction Basic Format:
Program code:


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 that will be included in this directive.
Attention:
1.


This document name: program code:


Current Time: Program code:


Your IP address is the program code:


#include demonstration
Role:
Inserts the contents of the 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 to the directory that contains the document that uses the #include directive. The included files can be in the same level directory or in their subdirectories, but not in the top level directory. File= "Nav_head.htm" If the nav_head.htm document is represented in the current directory.
The virtual file name is the full path to the virtualized directory on the Web site. File= "/hoyi/nav_head.htm" If the nav_head.htm file is relative to the Hoyi directory under the root directory of the server document;
Parameters:
file specifies the location that contains the files relative to this document
virtual Specifies the location relative to the root directory of the server document
Attention:
1. The file name must have an extension.
2, the included files can have any file extension, I think the most convenient to use the HTM extension directly, Microsoft Company recommended to use the. inc extension (it depends on your hobby).
Example:
Program code:
< #include file= "nav_head.htm"--Insert header file to current page
< #include file= "nav_foot.htm"--Inserts a tail file into the current page
< #include file= "nav_head.htm"--Insert header file to current page
< #include file= "nav_foot.htm"--Inserts a tail file into the current page
#flastmod and #fsize Demonstrations
Effect: Date #flastmod file was last updated
Length of #fsize file
Grammar:
Program code:




Parameters:
file specifies the location of the containing file relative to this document, such as Info.txt represents the Info.txt document in the current directory
virtual Specifies the location relative to the server document root directory, as/hoyi/info.txt represents
Attention:
The file name must have an extension.
Example:
Program code:


Inserts the last updated date of the news.htm file in the current directory into the current page
Program code:


News.htm the file size of the current directory into the current page
 
#exec Demonstration
Role:
Inserts the output of an external program into the page. You can insert a CGI program or an input to a regular application, depending on whether the parameter used is CMD or CGI.
Grammar:
Program code:




Parameters:
CMD general application
CGI CGI script program
Example:
Program code:
The password file will be displayed
The list of files in the current directory will be displayed
The CGI program gb.cgi will be executed.
The CGI program access_log.cgi will be executed.
The password file will be displayed
The list of files in the current directory will be displayed
The CGI program gb.cgi will be executed.
The CGI program access_log.cgi will be executed.
Attention:
As can be seen from the above example, this instruction is quite handy, but there are also security issues.
Forbidden Method:
. Apache, will be access.conf in the "Options includes execcgi" This line of code deleted;
. In IIS, to disable the #exec command, you can modify the SSIExecDisable metabase;

#config
Function: Specifies the format of the error message, date, and file size returned to the client browser.
Grammar:
Program code:






Parameters:
ErrMsg Custom SSI Executes the error message, which can be 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: Displaying a file size that does not exist
Program code:




Display file size in kilobytes
Program code:




Display time in a specific time format
Program code:

Show today is the day of the week, a few months, time zone



Show today is the day of the week, a few months, time zone


Xssi
Xssi (Extended SSI) is a set of advanced SSI instructions built into the Mod-include module in Apache 1.2 or later.
Among the available directives are:
#printenv
#set
#if
#printenv
Function: Displays all environment variables that currently exist in the Web server environment.
Syntax: Program code:


Parameters: None
Example:
Program code:


#set
  • Related Article

    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.