Use shtml to include Web page files (open SSI)

Source: Internet
Author: User
Tags add format end execution functions iis include dreamweaver
include| Web pages have been built in the web. When we encounter a lot of content for static pages, and the page header and footer often to be replaced, if always use HTML files always have a lot of trouble. Because the batch modification is not very good, we always want to be able to use the footer and the end of the page include in the HTML file. HTML is a client-side parsing format language, which is almost impossible to change since 4.0 (after all, many browsers only parse the 4.0 standard) and so far there is no such concept. While the HTML frame (frame and IFRAME) can be used to include the home page and footer file, the concept of frame and IFrame is different from that of the dynamic page (asp,jsp,php, etc.). Frame and the main page of the IFRAME and the included page is not a page, while the page through the inclusion of the main page and the page is included is still a page, so that the page reload when the impact of no speed, there will not be multiple windows such a problem. Of course, the role of frame and IFrame is quite large, but this is not the same as include in the concept of the page.

In addition to frame and IFRAME, the commonly used method of calling the file with JS. This is very close to the include concept, but can require client JS support, and the modification is not very important, Because the included JS is through document.write to output HTML code, so although to achieve the effect, can be JS after all the implementation of client dynamic effect better, such as the current more popular Ajax. So whether it is frame/iframe or JS is not the same as the include (but Dreamweaver in the library and include very similar, unfortunately only in Dreamweaver), and we sometimes page has a lot of static pages, Content is not dynamic and there is no law to follow, the more difficult to do in the database. such as Sina's news and so on, we can use the shtml way to do these pages. --jarryli in BeiJing

Then what is shtml?
Using the HTML file name extension for SSI (server Side include), SSI (server Side include), commonly referred to as "servers-side embedding" or "server-side inclusion," is an ASP-like server-based Web-making technology. The default extension is. stm,. shtm and. shtml.
What is SSI?
SSI is the abbreviation of English server Side includes, translated into Chinese is the meaning that server side contains. From a technical standpoint, SSI is a command or pointer that is in an HTML file that can be invoked through a comment line. SSI is powerful, with a simple SSI command that enables content updates throughout the site, dynamic display of time and dates, and the execution of complex functions such as shell and CGI scripts. Site maintenance often encountered a problem is that the structure of the site has been fixed, but in order to update a little content and have to redo a large number of pages. SSI provides a simple, effective way to solve this problem, it will be the basic structure of a Web site in a few simple HTML files (templates), we have to do is to upload text to the server, so that the program to follow the template to automatically generate Web pages, so that the management of large Web sites becomes easier.
How do you enable your Apache server to support SSI?
Apache (How to install Apache under Windows and Linuc see another two articles) by default, SSI is not supported, and we need to change httpd.conf to configure it. Here I take the Windows platform Apache 2.0.x for example (same as under Linux platform), open the httpd.conf file in the Conf directory, search "AddType text/html. shtml" and find:

# AddType text/html. shtml
# Addoutputfilter INCLUDES. shtml

Remove the # in front of these two lines.

Then search "Options Indexes followsymlinks"
Add "Includes" after the search to the line
The line will change to Options Indexes followsymlinks Includes

Familiarity with the Apache manual may feel easier.
Save httpd.conf, restart Apache
This completes the setup of the Apache SSI.
How to get your IIS server to support SSI
Windows 2000:
Add an application extension mapping in IIS
Executable file: C:\WINDOWS\system32\inetsrv\ssinc.dll
Extended Name: shtml/shtm
The SSI (shtml file) is supported by Windows 2003 2003 by default, and only in the Web service extension of IIS, set "include on server Side" to "Allow" You can IIS6.0 some improvements to SSI, which may not be available after the migration of some of the previously IIS5.0 programs.
A recurring problem occurs when the following error occurs:
"Error processing SSI file-Error processing SSI file"

After testing, the following practices can cause this error:
1, the server physical path uses the Chinese name.
2, including the use of Chinese names in the file.
3, the containing file does not exist.
4, the included file again contains documents using the Chinese name.

This error persists in Unicode encoding and is a problem with IIS.
Workaround: Use English for both the physical and URL addresses of the site using SSI.
shtml file test?
Principal files, such as test.shtml, with the contents of (Head.html and foot.html files in the same file as the include in asp,jsp,php)

<!--#i nclude file= "head.html"-->
The first file, for example, is named Head.html, and the content is

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://" >The footer file, for example, is named Foot.html, and the content is

I am the end of the page copyright information </body>
Then run the Web server, open the Test.shtml file in the address bar, and you will get a complete page, including headers and tails files.
Simple SSI commands in shtml
SSI is powerful, with a simple SSI command that enables content updates throughout the site, dynamic display of time and dates, and the execution of complex functions such as shell and CGI scripts. For example, we modify the test.shtml file mentioned above, add the following code, will display the server date and client IP, etc.:

<font color=red> This document name: <br> <!--#e cho var= "document_name"--> <br> time zone:<br> <!--#e Ch  o var= "date_local"--> <br> Your IP address is: <br> <!--#e cho var= "remote_addr"--><br> today is: <!--#c Onfig timefmt= "%A,%B%d,%Y"--> <!--#e cho var= "last_modified"--> <br> </font>
SSI Instruction Basic Format:
Program code:
<!-– directive name = "Instruction parameter" >
<!--#i nclude file= "head.htm"-->
1. <!----> is a comment in HTML syntax that is ignored when the Web server does not support SSI.
2. #i Nclude 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.
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.
Details can be viewed shtml detailed tutorials, through the shtml can alleviate a lot of work burden oh.
In addition: shtml files in the Web server to run under the effective, directly with IE open will be treated as a text file.

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: 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.