title: Nginx subfolder redirecting to url with trailing slash
body: <p>This is my setup:</p>
  
  <pre><code>location ~ \.php$ {
      include fastcgi_params;
      include fastcgi.conf;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php-fpm.sock;
      fastcgi_param SCRIPT_FILENAME /var/www/html/example.com$fastcgi_script_name;
      fastcgi_param SCRIPT_NAME $fastcgi_script_name;
      fastcgi_index index.php;
  }
  
  if ($request_uri ~* "^(.*/)index\.html$") {
      return 301 $1;
  }
  
  location / {
      root   /var/www/html/example.com;
      index  index.php index.html index.htm;
  }
  </code></pre>
  
  <p>When I go to url <code>https://example.com/subfolder</code> browser redirects me to <code>https://example.com/subfolder/</code> and if I try to remove trailing slash with <code>rewrite ^/(.*)/$ /$1 permanent;</code>, there are too many redirects.</p>
  
  <p>Is there a way to remove a trailing slash for subfolders?</p>