title: Protect subdirectory with .htaccess and .htpasswd
body: <p>I have a directory <code>memories</code> and there is a subdirectory in it <code>/memories/application/controllers/admin</code>.<br>
  I want to protect <code>admin</code> directory using <code>.htaccess</code> and <code>.htpasswd</code>.</p>
  
  <p>This is my <code>.htaccess</code> </p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      AuthUserFile /var/www/memories/application/controllers/admin/.htpasswd
      AuthType Basic
      AuthName "memories with mom"
      Require admin
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?/$1 [L]
  &lt;/IfModule&gt;
  &lt;IfModule !mod_rewrite.c&gt;
      ErrorDocument 404 /index.php
  &lt;/IfModule&gt;
  
  # Various security things
  ServerSignature off
  php_value expose_php Off
  php_value  session.cookie_httponly On
  Options -Indexes
  ErrorDocument 403 /404.php
  </code></pre>
  
  <p>But it is protecting the whole parent directory, whereas I only want the subdirectory <code>admin</code> to be protected. My <code>.htpasswd</code> is also in admin folder.</p>