title: Rewrite url with web.config for multiple variables in query string
body: <p>I am trying to make frindly URLs using web.config, and it must rewrite from 1 to (possibly) 2 variables and ignore rewrite if it's a directory name. So I have this URL:</p>
  
  <pre><code>http://www.domain.com/2014/ - Where 2014 is a folder.
  http://www.domain.com/2014/publications/ - It's one of the possible URLs
  http://www.domain.com/2014/publications/news/ - Another possible URL
  </code></pre>
  
  <p>While the real URLs  would be</p>
  
  <pre><code>http://www.domain.com/2014/
  http://www.domain.com/2014/?page=publications
  http://www.domain.com/2014/?page=publications&amp;subpage=news
  </code></pre>
  
  <p>I am trying this web.config but I am getting an error 500.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;system.webServer&gt;
          &lt;rewrite&gt;
              &lt;rules&gt;
                  &lt;rule name="Friendly 2"&gt;
                      &lt;match url="^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$" ignoreCase="false" /&gt;
                      &lt;conditions&gt;
                          &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Rewrite" url="/2014/index.php?page={R:1}&amp;subpage={R:2}" appendQueryString="false" /&gt;                  
                  &lt;/rule&gt;
              &lt;/rules&gt;
          &lt;/rewrite&gt;
      &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Am I missing something?</p>
  
  <p>Thanks in advance!</p>