0

I have a rule in url rewrite module like below

<rule name="articleSectionUrl">
  <match url="(.+)/([0-9]+)/(.+)/([0-9]+)" />
  <action type="Rewrite" url="article.aspx?articleid={R:4}" appendQueryString="false" />
</rule>

It works properly as it detects below type of article url's:
http://www.emusician.com/news/0766/spl-launches-usb-and-madi-interfaces/151461

That's fine, but it also detects below type of url, which is the image path unfortunately: http://www.emusician.com/Portals/9/SlideShowThumbnails/15/ad300x250_02.gif

Can anyone tell me how can i avoid this.

Abbas
  • 4,948
  • 31
  • 95
  • 161
  • Please ellaborate your exact case like: "I don't want to match any URL ending with [.gif]" or "I want my URL to only match when ending with a number" et cetera. – Menno May 06 '13 at 11:46
  • i don't want to match any image at the end of the url, it should just match if the url end's with number (an article id) only – Abbas May 06 '13 at 11:58

1 Answers1

0

Thanks all, @Aquillo as per your regex it will just limit the file whose extension I provide in the regex, that means I always have to provide the extensions in the regex for the url I want to ignore, so here's the complete solution to my problem.

UrlRewrite module has a <conditions> element under <rule> with this we limit any type of file which comes in the url.

Here's the complete solution:

<rule name="articleSectionUrl">
          <match url="(.+)/([0-9]+)/(.+)/([0-9]+)" />
          <action type="Rewrite" url="article.aspx?articleid={R:4}" appendQueryString="false" />
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            </conditions>
        </rule>

Thanks guys for helping me.

Abbas
  • 4,948
  • 31
  • 95
  • 161