410 A Bunch Of Html Pages In 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
Solution 1:
I do it this way:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if( listOf410urls.Contains(Request.RawUrl) )
{
Response.StatusCode = 410; Response.End();
}
}
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>
This means that all the pages that return 410 will be fetched to the user & search engines using /Error410.aspx
page.
In Error410.aspx I also set Response.StatusCode = 410;
otherwise the statuscode will be 200 OK.
Post a Comment for "410 A Bunch Of Html Pages In IIS"