使用 IIS 和 FastCGI 解析 .html 文件中的 PHP

发布于 2024-10-01 05:54:45 字数 141 浏览 0 评论 0原文

我有一个包含大量 .html 文件的大网站,我想开始在我的页面中使用 PHP,但我不想更改到 .php 的链接。我在 Apache 服务器上读到,您可以向 .htaccess 文件添加一条规则,以允许 PHP 在纯 .html 文件中进行解析。这在 IIS 中可能吗?

I have a big site with lots of .html files, and I want to start using PHP in my pages, but I don't want to change the links to .php . I read on Apache servers you can add a rule to the .htaccess file that will allow PHP parsing in plain .html files. Is this possible in IIS?

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

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

发布评论

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

评论(2

迷途知返 2024-10-08 05:54:45

绝对地。假设您使用的是 IIS7,只需将“Handler Mappings”中的请求路径更改为 *.html(以处理所有 html 文件)。

请注意,您的性能会受到很大影响。提供静态内容要快得多,因此如果您有大量 html 页面,那么每个页面都将开始由 PHP 解析。最好根据需要将页面切换到 .php,但我知道修复所有反向链接会很棘手。

有关设置的更多信息,请参阅 这里

Absolutely. Assuming you're using IIS7, you simply change the request path in "Handler Mappings" to *.html (to handle all html files).

Note that you'll get a big performance hit though. It's much quicker to serve static content, so if you have lots of html pages every single one of them will start being parsed by PHP. It would be preferable to switch pages to .php as needed, but I understand that it would be tricky to fix all the backlinks.

More information about setting it up is available here.

请爱~陌生人 2024-10-08 05:54:45

请注意,更改处理程序映射时,您还需要确保它仍然发送正确的 MIME 类型。我刚刚实现了 Hamish 链接到的解决方案,但我所有的 CSS @import 指令都失败了,因为它们针对的是纯 .css 文件,这些文件现在使用 PHP 的标准 text/html Content-type 标头提供服务。

Be aware that when changing handler mappings you'll also want to make sure it is still sending the correct MIME types. I just implemented the solution Hamish linked to, but all my CSS @import directives were failing, as they were to pure .css files which were now being served with PHP's standard text/html Content-type header.

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