Home  >  Article  >  Web Front-end  >  Explanation of the difference between shtml and html_HTML/Xhtml_Web page production

Explanation of the difference between shtml and html_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:41:551438browse

There are some similarities between shtml and asp. In the file named shtml, some SSI instructions are used, just like the instructions in asp. You can write SSI instructions in the SHTML file. When the client accesses these shtml files, the server It will read and interpret these SHTML files, and interpret the SSI instructions contained in the SHTML files.

The last sentence is the most useful. To put it simply, shtml looks nothing like html on the surface. There is a big difference, but when we use it, it is different. From our understanding of shtml, we can know that shtml can use . In this case, we can directly add our own advertising code or what we want to recommend The thing is quoted. The usage method is as follows:

In the middle of the document with the suffix shtml or shtm, insert this tag at the position you want to import the info.htm file. I mentioned above , I want to make a novel website. Everyone knows that it is best to generate static novel websites to reduce the load on the server. My website has always been static. After we use shtm to introduce advertisements, the most important point is, You can add the novels we want to recommend in info.htm. As we all know, if novelists want to change the recommended content of the page without regenerating the code, they can only use JS, but the search engine spider encounters JS. It will be ignored directly. If we use JS to recommend content, it may not be good for search optimization. However, if we use shtm, it will be different. Because we can use SSI instructions. We only need to use include to introduce info.htm , and then write the novels or other information that need to be recommended directly into info.htm, so that as long as it is shtm and the page that introduces info.htm will change accordingly, and the search engine will still crawl it. So much nonsense is mainly because I feel that this thing is very good and very convenient to use. So, after talking for a long time, I actually told my friends who work on the novel website that using shtm is still a good choice.
I didn’t know it was written like this Do you understand?
APACHE turns on shtml and modifies srm.con:AddType text/x-server-parsed-html .shtml. It will only parse SSI commands for files with .shtml extension
Windows seems to be the default server. If it is supported, just set "Included files on the server side" to "Allow" in the "Web Service Extension" of IIS.
If you want to get information about some html commands, please continue reading
Program code:
 
 
 For example, program code:
 
 
 Instructions:
 1. is a comment in HTML syntax. When the WEB server does not support SSI, this information will be ignored.
 2. #include is one of the SSI directives.
 3. file is the parameter of include, info.htm is the parameter value, which in this command refers to the name of the document to be included.
NOTE:
1. There is no space between  2. The above punctuation points = "", not one is missing.
 3. SSI instructions are case-sensitive, so parameters must be lowercase to have any effect.


Detailed explanation of the use of SSI command
#echo demonstration
Function:
Insert environment variables into the page.
Syntax:
Program code:

This document name: Program code:

Current time: Program code:

 
 Your IP address is the program code:
 
 #include demonstration
 Function:
 Insert the content of the text file directly into the document page.
Syntax:
Program code:


file The file name is a relative path, which is relative to the directory where the document using the #include directive is located. The included file can be in the same level directory or its subdirectory, but not in the upper level directory. If it represents the nav_head.htm document in the current directory, it is file="nav_head.htm".
The virtual filename is the full path to the virtual directory on the website. For example, it means relative to the nav_head.htm file in the hoyi directory under the server document root directory; it is virtual="/hoyi/nav_head.htm"
 Parameters:
 file specifies the location of the included file relative to this document
Virtual specifies the location relative to the server document root directory
Note:
1. The file name must have an extension.
2. The included files can have any file extension. I think it is most convenient to use the htm extension directly. Microsoft recommends using the .inc extension (it depends on your preference).
Example:
Program code:
Insert the header file into the current page
Insert the tail file into the current page
#flastmod and #fsize demonstration
Function: #flastmod File last updated date
#fsize file length
Syntax:
Program code:


Parameters:
file specifies the included file relative to this file The location of the document, such as info.txt, indicates the info.txt document in the current directory
. virtual specifies the location relative to the server document root directory, such as /hoyi/info.txt, which indicates
. Note:
. The file name must contain There is an extension.
Example:
Program code:

Insert the latest update date of the news.htm file in the current directory into the current page
Program code:

Insert the file size of news.htm in the current directory into the current page
#exec demonstration
Function:
Insert the output of an external program into the page. It can be inserted into CGI programs or as input to regular applications, depending on whether the parameters used are cmd or cgi.
Syntax:
Program code:


Parameters:
cmd regular application
cgi CGI script program
Example:
Program code:
will display the password file
will display the file list in the current directory
will execute the CGI program gb.cgi.
 The CGI program access_log.cgi will be executed.
Note:
As you can see from the above example, this command is quite convenient, but it also has security issues.
Prohibition method:
. Apache, delete the "Options Includes ExecCGI" line in access.conf;
 . In IIS, to disable the #exec command, you can modify the SSIExecDisable metabase;
 #config
 Function: Specify the format of error information, date and file size returned to the client browser.
Syntax:
Program code:



Parameters:
errmsg Custom SSI execution error message, can be anything you like way.
Sizefmt file size display mode, the default is bytes mode ("bytes") and can be changed to kilobyte mode ("abbrev")
timefmt time display mode, the most flexible configuration attribute.
Example: Display the size of a non-existent file
Program code:


Display the file size in kilobytes
Program code:

 
Display the time in a specific time format
Program code:

Display the day of the week, month and time zone

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn