万企互联-专注高端网站建设
扫描关注万企互联微信公众账号

扫一扫微信二维码

服务器IIS下自定义错误页面配置的两种方式

系统维护2022/2/14 309

1、首先进入你的网站主页,找到【错误页】(注意是IIS下的错误页不是.NET错误页),双击【错误页】

2、这样就进入了错误页面,点击【编辑】或者双击状态代码行,打开“编辑自定义错误页面”

3、填写状态码,响应操作处选择第二项【在此网站上执行】,输入URL

4、查看错误页面相对根目录的位置,按照示例填写就可以的。然后依次设置其它页面

5、当然还可以通过修改配置文件(web.config)来设置自定义页面,它和上面的配置是对应的。


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Custom">
            <remove statusCode="502" subStatusCode="-1" />
            <remove statusCode="501" subStatusCode="-1" />
            <remove statusCode="500" subStatusCode="-1" />
            <remove statusCode="412" subStatusCode="-1" />
            <remove statusCode="406" subStatusCode="-1" />
            <remove statusCode="405" subStatusCode="-1" />
            <remove statusCode="403" subStatusCode="-1" />
            <remove statusCode="401" subStatusCode="-1" />
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="401" prefixLanguageFilePath="" path="/ErrorPages/401.html" responseMode="ExecuteURL" />
            <error statusCode="404" prefixLanguageFilePath="" path="/ErrorPages/404.html" responseMode="ExecuteURL" />
            <error statusCode="403" prefixLanguageFilePath="" path="/ErrorPages/403.html" responseMode="ExecuteURL" />
            <error statusCode="405" prefixLanguageFilePath="" path="/ErrorPages/405.html" responseMode="ExecuteURL" />
            <error statusCode="406" prefixLanguageFilePath="" path="/ErrorPages/406.html" responseMode="ExecuteURL" />
            <error statusCode="412" prefixLanguageFilePath="" path="/ErrorPages/412.html" responseMode="ExecuteURL" />
            <error statusCode="500" prefixLanguageFilePath="" path="/ErrorPages/500.html" responseMode="ExecuteURL" />
            <error statusCode="501" prefixLanguageFilePath="" path="/ErrorPages/501.html" responseMode="ExecuteURL" />
            <error statusCode="502" prefixLanguageFilePath="" path="/ErrorPages/502.html" responseMode="ExecuteURL" />
            <error statusCode="503" prefixLanguageFilePath="" path="/ErrorPages/503.html" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>


<error  statusCode="404"  prefixLanguageFilePath=""  path="/ErrorPages/404.html" responseMode="ExecuteURL" />

有两个重要的点:状态码(statusCode)和路径(path),填写的时候要细心。


文章关键词
服务器
IIS
品控技术网 TOP图标库 万企互联 咸阳网站建设 域名转发系统 IP地址查询 万企工具 超越彼岸BEYOND 六佰号 秦川云 IDC主机测评 三秦人才网 陕西锦新橡塑制品有限公司