陋室铭
永远也不要停下学习的脚步(大道至简至易)

posts - 2167,comments - 570,views - 413万

网站自定义错误页面的设置,IIS下设置网站自定义错误页面

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

 

2、进入了错误页面,可以看到的是IIS默认的错误页面,点击【编辑】或者双击状态代码行,打开“编辑自定义错误页面”

 可以在IIS的默认安装目录下找到IIS默认的错误页面。(这里明显也可以直接把IIS默认的错误页面整体修改,不过这么做隐患很大不推荐)

 C:\inetpub\custerr\zh-CN

 

 

 

 

 

3、自定义错误页面,点击【添加】【编辑】或者双击状态代码行,打开“编辑自定义错误页面”

 

 

 

 

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

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

6、当然还可以通过修改配置文件(web.config)来设置自定义页面,它和上面的配置是对应的。(在IIS中修改web.config也会有相应变化)

复制代码
复制代码
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <configuration>
 3     <system.webServer>
 4         <httpErrors errorMode="Custom">
 5             <remove statusCode="502" subStatusCode="-1" />
 6             <remove statusCode="501" subStatusCode="-1" />
 7             <remove statusCode="500" subStatusCode="-1" />
 8             <remove statusCode="412" subStatusCode="-1" />
 9             <remove statusCode="406" subStatusCode="-1" />
10             <remove statusCode="405" subStatusCode="-1" />
11             <remove statusCode="403" subStatusCode="-1" />
12             <remove statusCode="401" subStatusCode="-1" />
13             <remove statusCode="404" subStatusCode="-1" />
14             <error statusCode="401" prefixLanguageFilePath="" path="/ErrorPages/401.html" responseMode="ExecuteURL" />
15             <error statusCode="404" prefixLanguageFilePath="" path="/ErrorPages/404.html" responseMode="ExecuteURL" />
16             <error statusCode="403" prefixLanguageFilePath="" path="/ErrorPages/403.html" responseMode="ExecuteURL" />
17             <error statusCode="405" prefixLanguageFilePath="" path="/ErrorPages/405.html" responseMode="ExecuteURL" />
18             <error statusCode="406" prefixLanguageFilePath="" path="/ErrorPages/406.html" responseMode="ExecuteURL" />
19             <error statusCode="412" prefixLanguageFilePath="" path="/ErrorPages/412.html" responseMode="ExecuteURL" />
20             <error statusCode="500" prefixLanguageFilePath="" path="/ErrorPages/500.html" responseMode="ExecuteURL" />
21             <error statusCode="501" prefixLanguageFilePath="" path="/ErrorPages/501.html" responseMode="ExecuteURL" />
22             <error statusCode="502" prefixLanguageFilePath="" path="/ErrorPages/502.html" responseMode="ExecuteURL" />
23             <error statusCode="503" prefixLanguageFilePath="" path="/ErrorPages/503.html" responseMode="ExecuteURL" />
24         </httpErrors>
25     </system.webServer>
26 </configuration>
复制代码
复制代码

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

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

posted on   宏宇  阅读(362)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2020-09-29 Sqlserver内存管理:限制最大占用内存
2020-09-29 常用期刊评价指标
2009-09-29 理解 __doPostBack(转)
2009-09-29 深入理解ArcGIS的地理坐标系、大地坐标系
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示