title: URL Rewrite in web.config of IIS to nginx.conf
body: <p>New to nginx, totally confused.</p>
  
  <p>How to convert this URL rewrite to nginx?</p>
  
  <pre><code>&lt;rewrite&gt;   
      &lt;rules&gt;
          &lt;rule name="IndexFolders" stopProcessing="true"&gt;
              &lt;match url="(.*[^/]+)$" /&gt;
              &lt;conditions&gt;
                  &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" /&gt;
              &lt;/conditions&gt;
              &lt;action type="Rewrite" url="/_index/{R:1}.html" /&gt;
          &lt;/rule&gt;
          &lt;rule name="OtherFile" stopProcessing="true"&gt;
              &lt;match url="\.\w+$" /&gt;
          &lt;/rule&gt;
          &lt;rule name="HtmlFile" stopProcessing="true"&gt;
              &lt;match url="^([^.]*[^/]+)$" /&gt;
              &lt;action type="Rewrite" url="{R:1}.html" /&gt;
          &lt;/rule&gt;
      &lt;/rules&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>Tried a converter, but not working.</p>
  
  <pre><code>location / {
      if (-d $request_filename){
          set $rule_0 1;
      }
      if ($rule_0 = "1"){
          rewrite /(.*[^/]+)$ /_index/$1.html last;
      }
      location ~* /\.\w+$ {
          break;
      }
      rewrite ^/([^.]*[^/]+)$ /$1.html last;
  }
  </code></pre>