I would like to 410 an entire directory - I deleted my blog

后端 未结 5 1340
萌比男神i
萌比男神i 2021-02-13 18:46

I had a folder called blog on my site. I deleted it all permanently. I would like to 410 it. How do i 410 an entire folder?

e.g. my site looked like this



        
5条回答
  •  孤独总比滥情好
    2021-02-13 19:17

    For those who are using IIS (7 or above) and stumble across this post as i did, this is how I wound up doing it using the global.asax:

    void Application_BeginRequest(object sender, EventArgs e)
    {
        HttpApplication app = sender as HttpApplication;
    
        if (app.Request.Url.PathAndQuery.IndexOf("/mydirectory") > -1)
        {
            Response.StatusCode = 410; Response.End();
        }
    }
    

    I happened to be looking for all pages in a directory, but I could have done something similar like targeting all html pages (assuming 410’ing ALL html pages were to be “gone”)

提交回复
热议问题