当浏览器请求的.html页面出现IIS 10错误(指定的CGI应用程序遇到错误)
我正在尝试在Windows Server 2019上的新IIS 10安装上重建网站。(这是一个在Windows2008R2测试箱上运行良好的网站。)当我在浏览器中请求索引index.html时,出现错误消息“指定的CGI应用程序遇到错误,服务器终止了该过程。”当我将页面重命名为index.htm时,它可以工作。
浏览器控制台中的错误显示:未声明HTML文档的字符编码。如果文档包含来自US-ASCII范围之外的字符,则在某些浏览器配置中,文档将呈现乱码。页面的字符编码必须在文档或传输协议中声明。
但是页面字符编码已正确声明,并且可以在另一台服务器上正常工作。
我的web.config看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
<handlers>
<clear />
<add name="PHP" path="*.html,*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="HTMLPHPMapping" path="*.html" verb="*" type="" modules="CgiModule" scriptProcessor="C:\php7\php-cgi.exe" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="PHP74Mapping" path="*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\php7\php-cgi.exe" resourceType="File" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="CGI-exe" path="*.exe" verb="*" type="" modules="CgiModule" scriptProcessor="" resourceType="File" requireAccess="Execute" allowPathInfo="true" preCondition="" responseBufferLimit="4194304" />
<add name="TRACEVerbHandler" path="*" verb="TRACE" type="" modules="ProtocolSupportModule" scriptProcessor="" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="OPTIONSVerbHandler" path="*" verb="OPTIONS" type="" modules="ProtocolSupportModule" scriptProcessor="" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile" path="*" verb="*" type="" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
</handlers>
<httpErrors errorMode="Custom" defaultResponseMode="File">
<clear />
<error statusCode="500" path="index.html" />
<error statusCode="404" path="index.html" />
</httpErrors>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="iisstart.htm" />
</files>
</defaultDocument>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".html" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>