本文介绍了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页面
发布评论