2

I have a webforms website I'm translating to MVC but I want certain url's that have been indexed to find their new url in the mvc site and I'm struggling with the one below:

http://www.domain.com/content/reviews/I_once_answered_a_question_in_SO_page512.aspx

And I want to translate it to a format like:

http://www.domain.com/view/512/I_once_answered_a_question_in_SO

So far the best I have:

<rule name="content pages" stopProcessing="true">
     <match url="^.*(?:content/(.*)_page([0-9]+)\.aspx)$" />
     <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
         <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
     </conditions>
     <action type="Redirect" url="/view/{R:2}/{R:1}"/>
</rule>

I think it's quite close but I can't see why it doesn't match.

David Aleu
  • 3,922
  • 3
  • 27
  • 48

1 Answers1

6

It's quite simple and you were quite close, indeed needs an extra condition between the content folder and the document page:

    <rule name="content pages" stopProcessing="true">
      <match url="^.*(?:content/(.*)/(.*)_page([0-9]+)\.aspx)$" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
        <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
      </conditions>
      <action type="Redirect" url="/view/{R:3}/{R:1}/{R:2}"/>
    </rule>
Ben
  • 76
  • 2