问题描述
在IIS 7.5中,是否可以单独使用 web.config 为 .html 扩展名的文件启用 SSI 处理?具体来说,我不想使用默认的SSI扩展名 .shtml 。
In IIS 7.5, is it possible to use web.config alone to enable SSI processing for files that have the .html extension? Specifically, I don't want to use the default SSI extension, .shtml.
原因:我不喜欢我想改变扩展名。这样做会导致搜索引擎结果中的链接断开。
Reason: I don't want to change the extensions. Doing so would lead to broken links in search engine results.
另外,我在 web.config 中执行此操作的动机是因为这是一个共享服务器。
Also, my motivation for doing this in web.config is because this is a shared server.
推荐答案
假设您的主机已启用SSI的和委托处理程序映射的读/写权限然后这应该工作:
Presuming that your hoster has enabled SSI's and delegated Read/Write permissions for handler mappings then this should work:
<configuration>
<system.webServer>
<handlers>
<add name="SSINC-html"
path="*.html"
verb="*"
modules="ServerSideIncludeModule"
resourceType="File"
requireAccess="Script" />
</handlers>
</system.webServer>
</configuration>
虽然我们讨论的是主题,但Robert McMurray(MSFT IIS职员)有一个相当近期的复习博客发布所有关于SSI的信息:
Whilst we're on the topic, Robert McMurray (MSFT IIS staffer) has a fairly recent refresher blog post all about SSI's here:
这篇关于使用web.config允许HTML文件(IIS)中的服务器端包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!