search
HomeWeb Front-endHTML Tutorial.html 、.htm 、 .shtml 以及 .shtm 四种扩展名的文件区别_html/css_WEB-ITnose

新增了一个分类,叫做 Personals,中文我把它解释成 "个人恶趣味",这里将记载一些对工作无关紧要,但是个人又一时有兴趣了解的东西。

今天要讲的是如题的 4 种扩展文件的区别。和大多数人一样,我首先接触到的也是 .html 后缀的文件,后来在工作中发现前端写的都是 .htm 后缀的文件,再后来接触到了 .shtml 的扩展文件,与它相应的还有 .shtm 的文件。遂花了一点时间了解了下它们之间的区别,记录如下。

.htm VS .html

首先来看 .htm 和 .html 文件的区别。答案居然是: 它们是相同的

事实上,这只是个人喜好问题,保持统一的后缀名即可。习惯上,windows 通常会用 .htm 的后缀名,而 linux(unix) 会用 .html 后缀(在 linux 中,如果打开 .htm 的文件,会直接展示源码)。这是因为很久以前,操作系统(DOS)的平台是 window 3.x.x,系统对于文件有个 8.3约束(8.3 naming convention),即文件名只能是 8 个字符,后缀只能是 3 个字符,所以当时显然无法使用 .html 后缀。而现在,这些问题都已经不复存在了。(个人感觉 .html 更正规一点,一些人认为使用 .htm 是回到了 dos 时代)

还有个问题是服务端的,如果服务端某文件夹下同时有 index.html 和 index.htm 文件,URL 省略了后面的文件名(如 http://www.domain.dom/dirname/),那么显然一个文件会优先于另一文件被读取(先解析 index.html)。事实上,我们一般不会在同一个文件夹下保存两个 index 文件。

.html VS .shtml

接着来说说 .html 和 .shtml 文件的区别,简单说 .shtml 文件就是 html 文件加个 ssi。那么,ssi 又是什么鬼?其实这玩意儿之前已经接触过,在 Apache下开启SSI配置使html支持include包含一文中。

SSI 是 Server Side Include 的首字母缩略词。包含有嵌入式服务器方包含命令的 HTML 文本。在被传送给浏览器之前,服务器会对 SHTML 文档进行完全地读取、分析以及修改。SSI 就是在 HTML 文件中,可以通过注释行调用的命令或指针。SSI 具有强大的功能,只要使用一条简单的 SSI 命令就可以实现整个网站的内容更新,时间和日期的动态显示,以及执行 shell 和 CGI 脚本程序等复杂的功能。 网站维护常常碰到的一个问题是,网站的结构已经固定,却为了更新一点内容而不得不重做一大批网页。SSI 提供了一种简单、有效的方法来解决这一问题,它将一个网站的基本结构放在几个简单的 HTML 文件中(模板),以后我们要做的只是将文本传到服务器,让程序按照模板自动生成网页,从而使管理大型网站变得容易。

应用它可以把网站中一些公共区域做成独立的页面,然后利用此技术嵌入到其它需要此区域内容的页面中去。

机制:

SSI 机制是 动态包含,而不是静态生成,是由 web服务器比如 apache 在收到用户的请求时,如果解析到其中有 SSI 包含指令时,自动取出被包含的页面嵌入到被请求的页面中一起当做一个整体的页面发送给用户,对用户来说根本不知道服务器做了啥,只是知道得到一个完整的页面。

由 SSI 工作机制我们知道,包含动作是在每次用户请求页面时发生,所以如果被包含的页面内容有变化,也能实时的反应出来,正因为如此,就很容易用来实现静态页面的动态嵌入,我们就可以用来实现网站中全站公共区域,或是 出现很多的重复区域内容发布成一个独立静态页面,然后在需要的地方用SSI指令包含进去, 比如像全站的头部和尾部,全站最新新闻等等。

事实上,.html 的文件同样可以开启 SSI,只需在 apache 里进行相应的配置,一旦开启 SSI,.html 文件和 .shtml 文件可以一样对待了。

AddType text/html .shtml .htmlAddOutputFilter INCLUDES .shtml .html

具体配置方法可以参考 Apache下开启SSI配置使html支持include包含

至于 .shtm 文件,window7 apache 下直接在浏览器中打开了源码。

Statement
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
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <iframe> tag? What are the security considerations when using it?What is the purpose of the <iframe> tag? What are the security considerations when using it?Mar 20, 2025 pm 06:05 PM

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.