title: What regex for a web.config will match part of a URL and allow anything after this text?
body: <p>I'm struggling with completing a regular expression for a web.config file in IIS 7.  We have several hundred pages that will be redirected (per a client request).  Many of these pages have URL patterns that are like this:</p>
  
  <ul>
  <li><a href="http://site/aaa-bbb/different1.html" rel="nofollow noreferrer">http://site/aaa-bbb/different1.html</a></li>
  <li><a href="http://site/aaa-bbb/different2.html" rel="nofollow noreferrer">http://site/aaa-bbb/different2.html</a></li>
  <li><a href="http://site/aaa-bbb/different-again/and-so-on.html" rel="nofollow noreferrer">http://site/aaa-bbb/different-again/and-so-on.html</a></li>
  </ul>
  
  <p>And we intend to redirect these requests to a common page like this:</p>
  
  <ul>
  <li><a href="http://site/aaa/bbb" rel="nofollow noreferrer">http://site/aaa/bbb</a></li>
  </ul>
  
  <p>There are over a dozen such URL patterns that I need to account for.  So I'm just trying to get this rewrite match to work, rather than applying all of their pages as key-value pairs in the rewrite map.  This is what I have so far, and you can see some of the attempts that I've commented out.</p>
  
  <pre><code>&lt;rewrite&gt;
    &lt;rewriteMaps&gt;
      &lt;rewriteMap name="301Redirects"&gt;
        &lt;add key="/index.htm" value="/" /&gt;
        &lt;add key="/index.html" value="/" /&gt;
        &lt;add key="/customPage.htm" value="/" /&gt;
      &lt;/rewriteMap&gt;
    &lt;/rewriteMaps&gt;
    &lt;rules&gt;
      &lt;rule name="301 Redirect Rule"&gt;
        &lt;match url=".*" /&gt;
        &lt;conditions&gt;
          &lt;add input="{301Redirects:{REQUEST_URI}}" pattern="(.+)" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Redirect" url="{C:1}" /&gt;
      &lt;/rule&gt;
  &lt;!-- Here is the rule I can't get to work. --&gt;
      &lt;rule name="301 to aaa/bbb" stopProcessing="true"&gt;
        &lt;match url="^/aaa-bbb([\d\w\s])" /&gt;
        &lt;!--&lt;match url="^/aaa-bbb(.{0,1})" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb(.?)" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb(.*)$" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb(\s\S)" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb[\s\S]*/([\s\S]*?(.htm|.html))" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb(.)" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb(.*)" /&gt;--&gt;
        &lt;!--&lt;match url="^/aaa-bbb([ _0-9a-z-]+)" /&gt;--&gt;
        &lt;action type="Redirect" url="/aaa/bbb" redirectType="Permanent" /&gt;
      &lt;/rule&gt;
    &lt;/rules&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>Now what does work, is if I enter the following URL.</p>
  
  <ul>
  <li><a href="http://site/aaa-bbb" rel="nofollow noreferrer">http://site/aaa-bbb</a></li>
  </ul>
  
  <p>That will successfully redirect to this:</p>
  
  <ul>
  <li><a href="http://site/aaa/bbb" rel="nofollow noreferrer">http://site/aaa/bbb</a></li>
  </ul>
  
  <p>But appending anything else at the end of that aaa-bbb winds up generating a 404 error.  Thanks for your help.</p>