Shtml and asp are similar. In files named after 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 will read and interpret these SHTML files and interpret the SSI instructions contained in the SHTML file.
The last sentence is the most useful. To put it simply, shtml does not look much different from html on the surface, but when we use it, it will be different. In our understanding of shtml, we can know that shtml can use <#include>, so that we can directly quote our advertising code or the things we want to recommend. The usage method is as follows:
In the middle of a document with shtml or shtm, insert this mark in the position you want to introduce the info.htm file. I mentioned above that I want to make a novel site. Everyone knows that it is best to generate static to reduce the load on the server. My site has always generated static. After we use shtm to introduce advertisements, the most important thing is that we can add the novel we want to recommend in info.htm. Everyone knows that if a novel is to change the recommended content of the page without regenerating the code, it is only used to use JS, but the spider of a search engine will ignore it when he encounters JS. If you use JS to recommend content, it may not be very good for search optimization, but if we use shtm, it will be different. Because you can use SSI instructions. Just use include to introduce info.htm, and then write the novels or other information you need to recommend directly into info.htm. In this way, as long as it is shtm and the pages that are introduced info.htm will change, and the search engines will still crawl. There is so much nonsense, mainly because I feel that this thing is very good and is very convenient to use. So I talked for a long time, but I actually told the guys who are doing novel sites that it is a good choice if you use shtm.
I don’t know if I have written so much. Do you understand?
APACHE enables shtml and modify srm.con:AddType text/x-server-parsed-html .shtml will only parse SSI instructions for files with .shtml extension.
It seems that the server is supported by default. You only need to set the included files on the server side in the IIS Web service extension as allowable.
If you want to get information about some html directives, please continue reading
Program code:
<!---- Instruction Name = Instruction Parameters>
<!---- Instruction Name = Instruction Parameters>
For example program code:
<!–#include file=info.htm–>
<!–#include file=info.htm–>
illustrate:
1. <!-- -> is annotation in HTML syntax. This information will be ignored when the WEB server does not support SSI.
2. #include is one of the SSI directives.
3. file is the parameter of include, info.htm is the parameter value, and refers to the document name to be included in this instruction.
Notice:
1. <!--There is no space between the # number, only the SSI instructions and parameters exist.
2. The above punctuation =, no one can be missing.
3. SSI instructions are case sensitive, so parameters must be lowercase to work.
Detailed explanation of the use of SSI instructions
#echo Demonstration
effect:
Insert environment variables into the page.
grammar:
Program code:
<!–#echo var=Variable name->
Name of this document: Program code:
<!–#echo var=DOCUMENT_NAME->
Current time: Program code:
<!–#echo var=DATE_LOCAL->
<!–#echo var=DATE_LOCAL->
Your IP address is the program code:
<!–#echo var=REMOTE_ADDR->
#include Demonstration
effect:
Insert the contents of the text file directly into the document page.
grammar:
Program code:
<!–#include file=File name->
<!–#include virtual=File name->
The file file name is a relative path relative to the directory where the document using the #include directive is located. The included files can be in the same level directory or its subdirectories, but not in the previous level directory. If the nav_head.htm document in the current directory is file=nav_head.htm.
The virtual file name is the full path to the virtual directory on the Web site. If it means the nav_head.htm file in the hoyi directory under the root directory of the server document; it is virtual=/hoyi/nav_head.htm
parameter:
file Specifies the location of the containing file relative to this document
virtual Specifies the location relative to the root directory of the server document
Notice:
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 hobby).
Example:
Program code:
<!-#include file=nav_head.htm->Insert the header file to the current page
<!-#include file=nav_foot.htm->Insert the tail file to the current page
#flastmod and #fsize demonstrations
Function: #flastmod file last update date
#fsize file length
grammar:
Program code:
<!–#flastmod file=File name->
<!–#fsize file=File name->
parameter:
file specifies the location of the containing file relative to this document, such as info.txt, which represents the info.txt document in the current directory.
virtual specifies the location relative to the root directory of the server document, such as /hoyi/info.txt
Notice:
The file name must have an extension.
Example:
Program code:
<!–#flastmod file=news.htm–>
Insert the latest update date of the news.htm file in the current directory into the current page
Program code:
<!–#fsize file=news.htm–>
Enter the file size of news.htm in the current directory into the current page
#exec Demonstration
effect:
Insert the output of an external program into the page. It can be inserted into CGI programs or input from a regular application, depending on whether the parameters used are cmd or cgi.
grammar:
Program code:
<!–#exec cmd=File name->
<!–#exec cgi=File name->
parameter:
cmd regular applications
cgi CGI script program
Example:
Program code:
<!-#exec cmd=cat /etc/passwd-> will display the password file
<!-#exec cmd=dir /b-> will display the list of files in the current directory
<!–#exec cgi=/cgi-bin/gb.cgi->The CGI program gb.cgi will be executed.
<!–#exec cgi=/cgi-bin/access_log.cgi->The CGI program access_log.cgi will be executed.
Notice:
As can be seen from the above example, this instruction is quite convenient, but there are also security issues.
Prohibited method:
. Apache, delete the Options Includes ExecCGI line in access.conf;
. In IIS, to disable the #exec command, you can modify the SSIExecDisable metadatabase;
#config
Function: Specifies the format of the error message, date and file size returned to the client browser.
grammar:
Program code:
<!–#config errmsg=custom error message->
<!–#config sizefmt=display unit->
<!–#config timefmt=display format->
parameter:
errmsg Custom SSI execution error messages can be used in any way you like.
sizefmt file size display method, default is byte method (bytes) can be changed to kilobyte method (abbrev)
timefmt Time display method, the most flexible configuration attribute.
Example: Shows the size of a file that does not exist
Program code:
<!–#config errmsg=The server execution error, please contact administrator Achuan, thank you! –>
<!–#fsize file=No file.htm->
Display file size in kilobytes
Program code:
<!–#config sizefmt=abbrev->
<!–#fsizefile=news.htm–>
Display time in a specific time format
Program code:
<!–#config timefmt=%Y year/%m month%d day and week %W Beijing time %H:%M:%s, %Y year has passed %j days Today is the %U week of %Y year->
<!–#echo var=DATE_LOCAL-> Shows what day of the week, month, and time zone it is today
<!-#config timefmt=Today's %A, %B, the server time zone is %z, yes->
<!–#echo var=DATE_LOCAL->