title: Block access to files in a directory but allow index.html
body: <p>I'm hosting a website on /test/ but files can be accessed by going to the url if user knows filename. Ex:</p>
  
  <pre><code>domain.com/test/readmesample.txt
  </code></pre>
  
  <p>I have it setup like above but now when i go to domain.com/test the index.html file wont load and I get a 403 forbidden. </p>
  
  <p>How can i set it up so when going to /test it allows the html file to load while still blocking files inside that directory? This includes files, folders and .files other than index.html. </p>
  
  <pre><code>location ~ /test {
               deny all;
  }
  </code></pre>
  
  <p>Here is my config file</p>
  
  <pre><code>server {
  listen 80;
  listen 443 ssl default_server;
  
  root /config/www;
  index index.html index.htm index.php;
  
  server_name www.domain.com;
  
  ssl_certificate /config/keys/letsencrypt/fullchain.pem;
  ssl_certificate_key /config/keys/letsencrypt/privkey.pem;
  ssl_dhparam /config/nginx/dhparams.pem;
  ssl_ciphers 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
  ssl_prefer_server_ciphers on;
  
  client_max_body_size 0;
  
  location / {
      try_files $uri $uri/ /index.html /index.php?$args =404;
  
  }
  
  location ~ /new {
      deny all;
  
  }       
  
  
  location ~ \.php$ {
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      # With php5-cgi alone:
      fastcgi_pass 127.0.0.1:9000;
      # With php5-fpm:
      #fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include /etc/nginx/fastcgi_params;
  }
  </code></pre>
  
  <p>Thank you in advance</p>