title: Regex find a string within an url, non case sensitive
body: <p>I have the url:</p>
  
  <pre><code>http://primarydomain.com/sites/secondarydomain/?foo=bar
  </code></pre>
  
  <p>What regex expression could I use to match the url for <code>sites/secondarydomain</code> - not case sensitive (this is for a rule in a web.config file but requires standard regex)?</p>
  
  <p>To put it into context, I am writing a web.config url rewrite rule to remove <code>sites/secondarydomain</code> from all urls (due to a multiple sites being hosted on the same package).</p>
  
  <pre><code>&lt;rule name="Remove full hosting path"&gt;
      &lt;match url="***Regex goes here***" ignoreCase="true"/&gt;
      &lt;action type="Redirect" url="http://secondary.com/{R:1}" redirectType="Permanent" /&gt;
  &lt;/rule&gt;
  </code></pre>
  
  <p>I am looking to match only the directories (not the query string) in order to redirect the user (hence removing the <code>sites/secondarydomain</code>).</p>
  
  <p>Update: It looks like I want to rewrite the url and not redirect, here is the current web.config rule that doesn't quite work:</p>
  
  <pre><code>    &lt;rule name="TestRule"&gt;
        &lt;match url=".*" /&gt;
        &lt;conditions&gt;
          &lt;add input="{PATH_INFO}" pattern="^(/hostedsites/clemones_htdocs)(/.*)"/&gt;
        &lt;/conditions&gt;
        &lt;action type="Rewrite" url="\{C:2}" appendQueryString="true" /&gt;
      &lt;/rule&gt;
  </code></pre>
  
  <p>Where my secondary domain is <a href="http://clemones.com/" rel="nofollow">http://clemones.com/</a>
  and the path I'm trying to get rid of: <a href="http://clemones.com/hostedsites/clemones_htdocs/" rel="nofollow">http://clemones.com/hostedsites/clemones_htdocs/</a></p>
  
  <p>FOR testing, <a href="http://clemones.com/shizzle" rel="nofollow">http://clemones.com/shizzle</a> works as a destination (hence sadly <a href="http://clemones.com/hostedsites/clemones_htdocs/shizzle" rel="nofollow">http://clemones.com/hostedsites/clemones_htdocs/shizzle</a> also works).</p>
  
  <p>Thanks in advance</p>