Static html file inclusion html implementation

Source: Internet
Author: User

Static html file inclusion html implementation

 

Static websites have public headers and tails that need to be included and do not want to be written on dynamic web pages. How can we implement the technology?

There are three methods:
1. IFrame, this may be the most familiar <iframe height = "30" marginheight = "0" marginwidth = "0" name = "neepage" src = "import.htm" width = "100%"> </iframe> some of its attributes can be transparent, no scroll bar or other specific effects. And his brother: Frameset.
2. JS implementation. html is loaded in the form of loading js. Generally, the advertisement adopts this form.
3. shtml. 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.

Shtml is the best choice for the first two. Shtml can contain specified files to the document, just like the include function in PHP. However, if shtml is required, the server must support 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.

There are two web servers:
I. nginx
Nginx already supports SSI, but it is disabled by default and needs to be enabled manually.
Open the Nginx configuration file nginx. conf and add the following three sentences to http.

 
  1. Ssi on;
  2. Ssi_silent_errors on;
  3. Ssi_types text/shtml;

Ps: the file type can be changed to another one. For example, if htm supports ssi, you can change text/shtml to text/htm. However, due to the large number of htm files on the server, it is not always necessary to use ssi to introduce other pages, which may cause unnecessary consumption to nginx. Therefore, we do not recommend that you do this.

If you want to add the default homepage, you can find the Index option in nginx. conf and change it
 
  1. Index index.shtml index.html index.htm

Save and restart nginx.

Ii. apache
Apache does not support SSI by default. We need to change httpd. conf for configuration.

 
  1. # AddType text/html. shtml
  2. # AddOutputFilter between des. shtml

Remove # from the front of the two rows.
Search Options Indexes FollowSymLinks.
Change to: Options Indexes FollowSymLinks Includes
Save httpd. conf and restart apache.

Only include is required for loading. Usage:
Virtual: the Virtual path to a document on the server. For example:
File: indicates the relative path to the current directory. The ../or absolute path cannot be used. For example:

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.