The difference between the four file extensions .html, .htm, .shtml and .shtm

The difference between the four file extensions .html, .htm, .shtml and .shtm
Many friends who have just started to make web pages find that there are so many extensions. In fact, htm and html are the same, and shtm and shtml are also the same. Note that for website optimization, it is recommended to use the same suffix. Basically, for visitors, html and htm can be two different contents.

.htm VS .html

First, let’s look at the difference between .htm and .html files. The answer is: they are the same.

In fact, this is just a matter of personal preference, just keep the same suffix. Traditionally, Windows usually uses the suffix .htm, while Linux (Unix) uses the suffix .html (in Linux, if you open a .htm file, the source code will be displayed directly). This is because a long time ago, the operating system (DOS) platform was window 3.xx, and the system had an 8.3 naming convention for files, that is, the file name can only be 8 characters and the suffix can only be 3 characters, so it was obviously impossible to use the .html suffix at that time. Now, these problems no longer exist. (Personally, I feel that .html is more formal. Some people think that using .htm is a return to the DOS era.)

Another problem is on the server side. If there are both index.html and index.htm files in a folder on the server, and the URL omits the file name (such as http://www.domain.dom/dirname/), then obviously one file will be read before the other (index.html will be parsed first). In fact, we usually don't save two index files in the same folder.

.html VS .shtml

Next, let's talk about the difference between .html and .shtml files. Simply put, a .shtml file is an html file with an ssi added. So, what the hell is SSI? In fact, I have come across this before, in the article Enable SSI configuration under Apache to make HTML support include.

SSI is the acronym for Server Side Include. HTML text containing embedded server-side include commands. The SHTML document is completely read, parsed, and modified by the server before being sent to the browser. SSI is a command or pointer that can be called through a comment line in an HTML file. SSI has powerful functions. With just one 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 scripts. A common problem encountered in website maintenance is that the structure of the website is 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 puts the basic structure of a website in a few simple HTML files (templates). All we have to do is upload the text to the server and let the program automatically generate web pages according to the template, making it easy to manage large websites.

By applying it, some public areas of the website can be made into independent pages, and then this technology can be used to embed them into other pages that need the content of this area.

mechanism:

The SSI mechanism is a dynamic inclusion rather than a static generation. When a web server such as Apache receives a user's request and parses it to find an SSI inclusion instruction, it automatically takes out the included page and embeds it into the requested page and sends it to the user as a whole page. The user has no idea what the server has done, but only knows that he has received a complete page.

From the working mechanism of SSI, we know that the inclusion action occurs every time a user requests a page, so if the content of the included page changes, it can be reflected in real time. Because of this, it is very easy to use it to realize dynamic embedding of static pages. We can use it to implement the public area of ​​the entire website, or publish a lot of repeated area content into an independent static page, and then include it with SSI instructions where needed, such as the header and footer of the entire site, the latest news of the entire site, etc.

In fact, SSI can also be enabled for .html files. You just need to make corresponding configurations in Apache. Once SSI is enabled, .html files and .shtml files can be treated the same.

AddType text/html .shtml .html
AddOutputFilter INCLUDES .shtml .html

For specific configuration methods, please refer to Enable SSI configuration under Apache to enable HTML to support include

As for the .shtm file, the source code was opened directly in the browser under window7 apache.

<<:  Simple CSS text animation effect

>>:  Specific use of Docker anonymous mount and named mount

Recommend

Distinguishing between Linux hard links and soft links

In Linux, there are two types of file connections...

Example code for implementing beautiful clock animation effects with CSS

I'm looking for a job!!! Advance preparation:...

How to install ELK in Docker and implement JSON format log analysis

What is ELK? ELK is a complete set of log collect...

Sample code for implementing form validation with pure CSS

In our daily business, form validation is a very ...

Issues with locking in MySQL

Lock classification: From the granularity of data...

JQuery implements hiding and displaying animation effects

This article shares the specific code of JQuery t...

Defining the minimum height of the inline element span

The span tag is often used when making HTML web p...

In-depth analysis of the diff algorithm in React

Understanding of diff algorithm in React diff alg...

How to deploy the crownblog project to Alibaba Cloud using docker

Front-end project packaging Find .env.production ...

Windows cannot start MySQL service and reports error 1067 solution

Suddenly when I logged into MySQL, it said that a...

Solution to the impact of empty paths on page performance

A few days ago, I saw a post shared by Yu Bo on G...

How to use cutecom for serial communication in Ubuntu virtual machine

Using cutecom for serial communication in Ubuntu ...