6

I've got rewrite module working great for my IIS7.5 site.

Now, I wish to add a number of URLs that all go to an HTTP 410-Gone status.

Eg.

<rule name="Old Site = image1" patternSyntax="ExactMatch" stopProcessing="true">
  <match url="image/loading_large.gif"/>
  <match url="image/aaa.gif"/>
  <match url="image/bbb.gif"/>
  <match url="image/ccc.gif"/>
  <action type="CustomResponse" statusCode="410"
            statusReason="Gone"
            statusDescription="The requested resource is no longer available" />
</rule>

but that's invalid - the website doesn't start saying there's a rewrite config error.

Is there another way I can do this? I don't particularly want define a single URL and ACTION for each URL.

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Pure.Krome
  • 6,508
  • 18
  • 73
  • 87

2 Answers2

9

You need to match every request, and then use conditions to filter it to just your specific URLs:

<rule name="Old Site = Image1" stopProcessing="true">
    <match url="^(.*)$" />
    <conditions logicalGrouping="MatchAny">
        <add input="{REQUEST_URI}" pattern="^(.*)image/aaa.gif$" />
        <add input="{REQUEST_URI}" pattern="^(.*)image/bbb.gif$" />
        <add input="{REQUEST_URI}" pattern="^(.*)image/ccc.gif$" />
    </conditions>
    <action type="CustomResponse" statusCode="410" statusReason="Gone" statusDescription="The requested resource is no longer available" />
</rule>
Mark Henderson
  • 68,823
  • 31
  • 180
  • 259
  • Brilliant :) thanks mate :) Now that every request is caught, I need to be wary of load/perf if we reach that problem. Ta! – Pure.Krome Dec 04 '12 at 01:45
0

if you would like to remove multiple .gif image from image folder then you can also use (.*) wildcard regex like below.

eg.


<rule name="Old Site = Image1" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
    <add input="{REQUEST_URI}" pattern="^(.*)image/(.*).gif$" />
</conditions>
<action type="CustomResponse" statusCode="410" statusReason="Gone" statusDescription="The requested resource is no longer available" />