410一堆IIS中的html页面

编程入门 行业动态 更新时间:2024-10-14 04:23:13
本文介绍了410一堆IIS中的html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在一堆html页面上为在IIS上运行的站点执行410 Gone。是否有一种简单的方法可以同时执行所有操作,例如htaccess文件,或者我是否必须在IIS中一次执行一次?

I need to do a 410 Gone on a bunch of html pages for a site running on IIS. Is there a simple way to do them all at once, like an htaccess file, or do I have to do it one at a time in IIS?

推荐答案

我这样做:

protected void Application_BeginRequest(Object sender, EventArgs e) { if( listOf410urls.Contains(Request.RawUrl) ) { Response.StatusCode = 410; Response.End(); } }

然后我在webconfig system.webServer

And then I have in webconfig system.webServer

<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL"> <remove statusCode="410" subStatusCode="-1" /> <error statusCode="410" path="/Error410.aspx" responseMode="ExecuteURL" /> </httpErrors>

这意味着返回410的所有页面都将被提取给用户&搜索引擎使用 /Error410.aspx 页面。

This means that all the pages that return 410 will be fetched to the user & search engines using /Error410.aspx page.

在Error410.aspx中我还设置了 Response.StatusCode = 410; 否则状态代码将为200 OK。

In Error410.aspx I also set Response.StatusCode = 410; otherwise the statuscode will be 200 OK.

更多推荐

410一堆IIS中的html页面

本文发布于:2023-11-12 19:58:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582395.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   IIS   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!