繁体   English   中英

结合web.config文件

[英]Combining web.config files

如果可以,需要将这些结合起来的帮助。

一种是允许.html和.htm文件的行为类似于某些包含项的.asp文件,另一种则是用于自定义404页面。

我尝试了各种变体,但是除了单独使用文件之外,所有其他操作都给我一个'500-Internal Server Error'消息。

web.config 1:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>

web.config 2:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>

这应该工作。 检查父级web.config文件,并查找由继承引起的问题。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<handlers>
<add name="htmlinc" path="*.html" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
<add name="htminc" path="*.htm" verb="*" modules="ServerSideIncludeModule" resourceType="Unspecified" />
</handlers>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.htm" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.htm" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/404.htm" />
</customErrors>
</system.web>
</configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM