title: Nginx configuration causing too many redirects
body: <p>I have a conf file with example.com as the root. In the example.com directory, there is an html, css, img, and js folder. I understand this deviates from the traditional html directory as root. I have tried many different configurations (using regex based on filetypes, variables, etc.) but I always get too many redirect errors. Can anyone help on a good conf file for this type of directory structure? Here is my conf file currently.</p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server;
      # return 301 https://$server_name$request_uri;
  
      listen 443 ssl http2 default_server;
      listen [::]:443 ssl http2 default_server;
      include snippets/ssl-example.com.conf;
      include snippets/ssl-params.conf;
  
      server_name www.example.com example.com;
  
      root /var/www/www.example.com/;
      index index.php index.html;
      client_max_body_size 100m;
  
      error_page 404 = error.html?error=404;
  
      location ~ /.well-known {
              allow all;
      }
  
      location / {
              location ~* \.(html|php)$ {
                     root html/;
              }
              location ~* \.css$ {
                     root css/;
              }
              location ~* \.js$ {
                     root js/;
              }
              location ~* \.(png|jpeg|gif)$ {
                     root img/;
              }
              try_files $uri =404;
      }
  }
  </code></pre>
  
  <p>Thanks in advance for any help!</p>