title: NGINX 301 remove .html from url, but not for files from a specific path (folder)
body: <p>In my <code>location /</code> directive I have added the following if statement to redirect all requests with the .html extension to the non-extension url:</p>
  <pre><code>if ($request_uri ~ ^/(.*)\.html) {
      return 301 /$1$is_args$args;
  }
  </code></pre>
  <p>This works fine, but actual .html files are also being redirected which results in a 404. I want to avoid this by adding an exception for all requests if the the url contains the directory &quot;/static/&quot;, but I am not sure how to do that. I tried to add the following if statement before the if statement above:</p>
  <pre><code>if ($request_uri ~ /static/) {
  
  }
  </code></pre>
  <p>But I'm not sure what to put in it to stop it from executing the .html if statement. Return $host$request_uri doesn't work, unfortunately.</p>
  <p>How would I be able to do this? I cannot use location directives due to limitations of my host. Everything is being done in in the <code>location /</code> directive.</p>