0

Looking for a method we can use in our ASP.NET MVC-5 IIS-8 site to return a 410 error response (gone) based on a list of phrases contained in the querystrings.

Why? We're receiving a few hundred daily junk hits from reputable bots (e.g., Google, Bing, Yahoo) for ridiculously named pages that we've never had on our site. I'm thinking that for most of these pages I can test if a given key-phrase exists and, if it does, return the 410. I'd like to return the 410 to tell the bots they can remove their listing permanently thereby providing a gradually improved SEO environment.

Here's a few examples of URL's we're receiving with the key-phrase I would test for in bold.

https://www.example.com:443/apple-touch-icon-precomposed.png

http://ww.w.example.com:80/zdjqhhmtkatt.html

I know this is very do-able with .htaccess in other programming environments so I'm hoping there's also an elegant solution for ASP.MVC.

Victor Leontyev
  • 8,488
  • 2
  • 16
  • 36
mark d
  • 126
  • 2
  • 7

1 Answers1

1

You can do that with URL rewrite module. The rule in your web.config should be like that:

<rewrite>
    <rules>
        <rule name="410response" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
                <add input="{REQUEST_URI}" pattern="apple-touch" />
                <add input="{REQUEST_URI}" pattern="zdjqhhmtkatt" />
            </conditions>
            <action type="CustomResponse" statusCode="410" statusReason="System unavailable" statusDescription="Gone. The requested resource is no longer available." />
        </rule>
    </rules>
</rewrite>
Victor Leontyev
  • 8,488
  • 2
  • 16
  • 36