为什么有些动态网站的页面是html格式的?

发布于 2024-08-18 05:17:53 字数 135 浏览 2 评论 0原文

我在互联网上看到过很多动态网站,它们的页面都是 html 或 htm 格式。我不明白这是为什么?他们是如何做到的?

只要看看这个网站:http://www.realmadrid.com/cs/Satellite/en/Home.htm

I've seen a lot of dynamic website through the internet that their pages are in html or htm format . I don't get it why is that ? And how they do that ?

Just look at this website : http://www.realmadrid.com/cs/Satellite/en/Home.htm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

司马昭之心 2024-08-25 05:17:53

您在 URL 中看到的内容可以由网站运行人员随意设置。该技术称为 URL 重写。

如何

在 Apache 上,最流行的解决方案是 mod_rewrite 模块。

鉴于您已标记 ASP.NET:据我所知,ASP.NET 仅提供有限的开箱即用重写支持。此博客条目承诺 ASP 2.0 中的完整 URL 重写解决方案

为什么

至于为什么这样做,没有令人信服的技术原因。

只是 htm 和 html 是 HTML 内容公认的标准扩展,许多人(包括我自己)认为它们只是看起来比 .php、.php5、.asp、.aspx 等更好。

此外,正如 Adam Pope 在他的回答中指出的那样,这使得使用哪种服务器端技术/语言变得不太明显。

.html/.htm 扩展名具有额外的效果,如果将其保存到磁盘,它通常会自动与您安装的浏览器连接。

也许(可能很大)有非常愚蠢简单的客户端程序认识到它们必须通过查看扩展来解析HTML。但这是公然违反规则的行为,希望最后一次出现是在 1994 年。无论如何,我认为这种情况不会再出现了。

What you see in the URL can be set at will by the people running the web site. The technique is called URL rewriting.

How

On Apache, the most popular solution to that is the mod_rewrite module.

Seeing as you've tagged ASP.NET: As far as I know, ASP.NET has only limited rewriting support out of the box. This blog entry promises a complete URL rewriting solution in ASP 2.0

Why

As for the why, there is no compelling technical reason to do this.

It's just that htm and html are the recognized standard extensions for HTML content, and many (including myself) think they simply look nicer than .php, .php5, .asp, .aspx and so on.

Also, as Adam Pope points out in his answer, this makes it less obvious which server side technology/language is used.

The .html/.htm extension has the additional effect that if you save it to disk, it is usually automatically connected with your installed browser.

Maybe (a very big maybe) there are very stupid simple client programs around that recognize that they have to parse HTML by looking at the extension. But that would be a blatant violation of rules and was hopefully last seen in 1994. Anyway, I don't think this is the case any more.

风蛊 2024-08-25 05:17:53

潜在的原因有很多,其中可能包括:

  • 他们可能试图隐藏构建网站所用的技术
  • 他们可能正在提供写入 HTML 的页面的缓存版本。
  • 他们可能只是认为它对用户来说看起来更友好

There are a number of potential reasons, these may include:

  • They could be trying to hide the technology they built the site with
  • They could be serving a cached version of a page which was written out to HTML.
  • They could simply perceive it to look friendlier to the user
听不够的曲调 2024-08-25 05:17:53

他们可能使用服务器端脚本语言,例如 PHP 或 ASP。您可以通过编辑 Web 服务器配置文件来配置该语言解析哪些文件扩展名。

例如,在 PHP 中,默认扩展名是 .php,但您可以将服务器配置为使用 .html,这意味着任何具有 .html 扩展名的文件都可以包含 PHP 代码,它们将在页面发送到客户端 Web 浏览器之前进行解析。

通常不建议这样做,因为它会增加开销,而且 PHP 引擎无论如何都会解析没有任何 PHP 的 .html 页面,这比直接向浏览器提供页面要慢。

另一种方法是使用某种形式的 URL 重写。请参阅 ASP.NET 中的 URL 重写

They might be using a server-side scripting language like PHP or ASP. You can configure what file extensions get parsed by the language by editing the web server configuration files.

For example in PHP the default extension is .php but you could configure the server to use .html, that would mean any files with the .html extension could contain PHP code they would get parsed before the page is sent to the clients web browser.

This is generally not recommend as it adds an overhead and .html pages that don't have any PHP would be parsed by the PHP engine anyway which is slower then serving pages direct to the browser.

The other way would be to use some form of URL rewriting. See URL Rewriting in ASP.NET

冷情 2024-08-25 05:17:53

另一个原因是SEO(搜索引擎优化)。许多搜索引擎喜欢 html 页面,许多人(我指的是一些 SEO 专家)认为 html 可以提高其内容在搜索引擎中的排名。

Another reason is SEO(Search engine optimization). Many search engines like html pages and many guys(I mean some SEO specialists) think the html can improve the rank of their content in search engine.

南渊 2024-08-25 05:17:53

一种可能只是历史原因。最初是静态的页面,现在是动态生成的,但网站不想破坏老客户的最爱。

One possibility is just historical reasons. Pages that started static, now are generated dynamically, but sites don't want to break old customer's favorites.

美男兮 2024-08-25 05:17:53

他们将某些页面保留为 html,因为它们的内容不应该经常更改或根本不更改。

但您还应该记住,有些网站是动态的,但它们将页面扩展更改为 html,但原始页面保持不变,例如 php 或 aspx 等,使用 htaccess 或某些框架(如 codeigniter 等)。

They keep some pages as html because their content is not supposed to change frequently or not at all.

But you should also keep in mind the fact that some sites are dynamic but they change the page extention to html but original page remains same eg php or aspx, etc using htaccess or some frameworks like codeigniter etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文