Home > Web Front-end > HTML Tutorial > Static html files contain the implementation of html_html/css_WEB-ITnose

Static html files contain the implementation of html_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:48:12
Original
1395 people have browsed it

More: http://www.webyang.net/Html/web/article_139.html


For static websites, there are public headers and tails that need to be included , and I don’t want to use dynamic web pages to write it. So how to implement it technically?

There are three methods:
1. IFrame, this may be the most familiar plus some of its attributes can achieve some specific effects such as transparency and no scroll bars. and his brothers: Frameset et al.
2. JS implementation, by loading js, the html is loaded in. Generally, advertisements take this form.
3. shtml. The html file extension using SSI (Server Side Include), SSI (Server Side Include), usually called "server-side embedding" or "server-side include", is a server-based web page production technology similar to ASP. The default extensions are .stm, .shtm, and .shtml.

Compared with the first two, shtml is the best choice. shtml can include specified files into the document similar to the include function in PHP. But if you need to use shtml, you need the server to support SSI.

SSI is the abbreviation of English Server Side Includes. Translated into Chinese, it means server side inclusion. Technically speaking, SSI is a command or pointer that can be called through a comment line in an HTML file. SSI has powerful functions. With a simple SSI command, you can update the content of the entire website, dynamically display time and date, and execute complex functions such as shell and CGI script programs. A problem often encountered in website maintenance is that the structure of the website has been fixed, but a large number of web pages have to be redone in order to update a little content. SSI provides a simple and effective way to solve this problem. It places the basic structure of a website in several simple HTML files (templates). In the future, all we have to do is to pass the text to the server and let the program Automatically generate web pages based on templates, making it easy to manage large websites.

Let’s talk about two web servers:
One: nginx
Nginx itself already supports SSI, but it is not enabled by default and needs to be enabled manually.
Open the Nginx configuration file nginx.conf and add the following three sentences to http.

          <ol>              <li>ssi on;</li>              <li>ssi_silent_errors on;</li>              <li>ssi_types text/shtml;</li>          </ol>
Copy after login

ps: The file type here can be changed to other ones. For example, if htm also supports ssi, then just change text/shtml to text/htm. However, in this case, due to the htm file in the server There are many, and not all of them may be imported into other pages using SSI, which will cause unnecessary consumption of nginx, so it is not recommended to do so.

If you need to add a default homepage, you can find the Index option in nginx.conf and change it to
          <ol>              <li>Index index.shtml index.html index.htm</li>          </ol>
Copy after login

Save and restart nginx.

2: apache
Apache does not support SSI by default, and we need to change httpd.conf to configure it.

          <ol>              <li>#AddType text/html .shtml</li>              <li>#AddOutputFilter INCLUDES .shtml</li>          </ol>
Copy after login

Remove the # in front of these two lines.
Then search for "Options Indexes FollowSymLinks"
Modify to: "Options Indexes FollowSymLinks Includes"
Save httpd.conf and restart apache

Loading only requires include, usage:
Virtual: Gives a virtual path to a document on the server side. For example:
File: gives the relative path to the current directory, in which "../" cannot be used, nor absolute path. For example:

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template