title: How can I deny all but one directory name with .htaccess?
body: <p>I have this .htaccess file where I prevent users from physically accessing files from the browser (where they should only be loaded through the system)</p>
  
  <pre><code>Options -Indexes
  Order deny,allow
  deny from all
  </code></pre>
  
  <p>I have one problem though, sometimes I load files via AJAX and there I get 403 Forbidden. I have little experience with apache's mod_access. I've been reading up on the <a href="http://httpd.apache.org/docs/1.3/mod/core.html#directory" rel="nofollow noreferrer">directory directive</a> since all my AJAX based files are in one directory called ajax.</p>
  
  <p>But the thing is I need to deny access to all directories except ones called ajax and my regex skills are lacking.</p>
  
  <p>An example directory structure is like this.</p>
  
  <pre><code>plugins/inventory/ajax
  plugins/inventory/controller
  plugins/inventory/view
  
  plugins/packages/ajax
  plugins/packages/controller
  plugins/packages/view
  </code></pre>
  
  <p>The .htaccess file sits in the plugins directory.</p>