Apache SHTML web page SSI Usage Details

Source: Internet
Author: User
Tags echo command

Method 1: The following describes how to configure apache to support shtml.
Enable the mongodes module to run shtml
0. Enable the php installation directory (under my Directory D: \ wamp \ Apache2 \ conf) in the httpd. conf file (about-rows ):
1. AddType text/html. shtml
AddOutputFilter between des. shtml
2. (F:/shz is the place where the running file is stored)
DocumentRoot "F:/shz" (about 150)
<Directory "F:/shz"> (about 178)
3. Add + pair des to Options Indexes FollowSymLinks.
For example: Options Indexes FollowSymLinks + des (about 197 ):
Need to restart apache );
Method 2: Let apachesupport .shtml to enable apache to support include tags
Open the httpd. conf file in the conf directory and search "AddType text/html. shtml". The search result is:
To: Copy codeThe Code is as follows: AddType text/html. shtml
AddOutputFilter between des. shtml
Options Indexes FollowSymLinks includes

Save httpd. conf and restart apache.
Now we have completed the configuration of Apache SSI.
<! -- # Include file = "index. php" -->

I personally think that the advantage of SSI is that it is more convenient to perform dynamic processing in the static mode, such as leaving messages in news.

The following is a detailed description
Because batch modification is not very convenient, we always hope to include the footer and footer to the html file. Html is a formatting language for client-side parsing. Since 4.0, it is almost difficult to make major changes (after all, many browsers only follow the 4.0 standard for parsing), so there is no such concept as include so far. Although the html framework (frame and iframe) can be used to contain homepage and footer files, the concept of frame and iframe and dynamic pages (asp, jsp, php, etc.) are used) the include of frame and iframe are different from those of the included page, the page Subject Page called by using the include method and the included page are still a page, so that the page is reloaded with no speed impact, there will be no such problem with multiple windows. Of course, the role of frame and iframe is quite big, but this is different from the concept of include pages.

In addition to frame and iframe, js is also commonly used to call files. This is very similar to the include concept, but it can be supported by the client js, and the modification is not very good, because the included js is through document. write to output html code, so that although it can achieve the effect, js can execute the client dynamically after all, for example, the more popular AJAX. Therefore, both frame, iframe, and js are different from include (the library in Dreamweaver is similar to include, but unfortunately it can only be used in Dreamweaver), and sometimes there are many static pages on the page, the content is not dynamic and there are no rules to follow, so it is worse to go to the database. For example, Sina news, we can use the shtml method to make these pages.

What is shtml?
Use the html file extension of SSI (Server Side Include). SSI (Server Side Include) is usually called "Server-Side embedding" or "Server-Side inclusion ", is a server-based web page creation technology similar to ASP. The default extensions are. stm,. shtm, And. shtml.

What is SSI?
SSI is the abbreviation of Server Side encryption DES. Technically speaking, SSI is a command or pointer that can be called through the annotation line in an HTML file. SSI has powerful functions. You only need to use a simple SSI command to dynamically display the content update, time, and date of the entire website, and complex functions such as shell and CGI scripts. A common problem with website maintenance is that the website structure is fixed, but a large number of webpages have to be redone to update a little content. SSI provides a simple and effective method to solve this problem. It places the basic structure of a website in several simple HTML files (templates ), in the future, all we need to do is to upload text to the server so that the program can automatically generate webpages according to the template, making it easy to manage large websites.

How can your Apache server support SSI?
Apache (for how to install apache in windows and linuc, see the other two articles) does not support SSI by default. We need to change httpd. conf for configuration. Take Apache 2.0.x on windows as an example (same as Apache 2.0.x on linux). Open httpd In the conf directory. conf file, search for "AddType text/html. shtml ", find:
The following is a reference clip:Copy codeThe Code is as follows: # AddType text/html. shtml
# AddOutputFilter between des. shtml
Remove # from the front of the two rows.
Search "Options Indexes FollowSymLinks"
Add "des" after the row to be searched"
Change this row to Options Indexes FollowSymLinks Includes
It may be easier to get familiar with apache manual.
Save httpd. conf and restart apache.

Now we have completed the configuration of Apache SSI.

SSI command:

1. Config command
The Config command is mainly used to modify the default settings of SSI. Where:

Errmsg: sets the default error message. To return user-defined error messages normally, the Errmsg parameter in the HTML file must be placed before other SSI commands; otherwise, the client can only display default error messages, instead of user-defined information.

<! -- # Config errmsg = "Error! Please email webmaster@mydomain.com -->

Timefmt: defines the format of the date and time. The Timefmt parameter must be used before the echo command.

<! -- # Config timefmt = "% A, % B % d, % Y" -->
<! -- # Echo var = "LAST_MODIFIED" -->

The result is: Wednesday, limit l 12,200 0.

Sizefmt: determines whether the file size is expressed in bytes, kilobytes, or megabytes. In bytes, the parameter value is "bytes". You can use the abbreviations for kilobytes and megabytes. Similarly, the sizefmt parameter must be placed before the fsize command.

<! -- # Config sizefmt = "bytes" -->
<! -- # Fsize file = "index.html" -->

2. Include command

The Include command can insert text or images from other documents into the currently parsed documents, which is the key to the entire SSI. By using the Include command, you only need to change one file to instantly update the entire site!

The Include command has two different parameters:

Virtual: the Virtual path to a document on the server. Example: <! -- # Include virtual = "/includes/header.html" -->

File: Specifies the relative path to the current directory. "../" cannot be used or an absolute path. Example: <! -- # Include file = "header.html" -->

In this case, each directory contains a header.html 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: 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.