title: Password Protected Directory [cPanel] - Receiving no Login Prompt and Error 401
body: <p>I have customized error pages setup on my site for the 302, 401, 403, 404 and 500 HTTP error codes. The five custom error page files are stored in the home directory.</p>
  
  <p>I would also like to protect a specific directory with a password and have tried doing so with cPanel's "Password Protect Directories" feature.</p>
  
  <p>I should also mention that in the home directory, there is an <code>.htaccess</code> file, with the following:</p>
  
  <pre><code>&lt;limit GET POST PUT&gt;
  order deny,allow
  allow from all
  &lt;/limit&gt;
  
  Options -Indexes
  
  ErrorDocument 302 /302.php
  ErrorDocument 401 /401.php
  ErrorDocument 403 /403.php
  ErrorDocument 404 /404.php
  ErrorDocument 500 /500.php
  </code></pre>
  
  <p>With that out of the way, I can now explain what's currently happening with this setup. Essentially, rather than the web browser prompting for the username and password, the password-protected page simply goes straight to the <code>401.php</code> error page.</p>
  
  <p>I've tried moving the error pages to their own directory, <code>/error/</code>, I've tried using cPanel's own error page setup tool (which uses <code>.shtml</code> files), and I've also tried a combination of cPanel's error pages and my own.</p>
  
  <p>From my testing, it seems that cPanel's <code>.shtml</code> error pages work, but they are ugly and don't match the theme of the website. The error pages I made, use PHP to require files for the theme, as well as to echo back the user's requested URL.</p>
  
  <p>I also seemingly had the combination of both sets of error pages working, even after I reuploaded the home directory's <code>.htaccess</code> file, but upon removing the set that cPanel made, everything broke again. I also don't know if it's good practice to use two sets of error pages, as follows:</p>
  
  <pre><code>&lt;HOME_DIR&gt;
  --- &lt;DIR&gt;
      --- .htaccess (contains code for password protection)
      --- index.php
  --- .htaccess (links to PHP error pages)
  --- 302.php
  --- 302.shtml
  --- 401.php
  --- 401.shtml
  --- 403.php
  --- 403.shtml
  --- 404.php
  --- 404.shtml
  --- 500.php
  --- 500.shtml
  --- index.php
  </code></pre>
  
  <p>This is something that I've never experienced before. From what I can ascertain, the problem is coming from the <code>.htaccess</code> file under the home directory, but I'm not 100% on that.</p>
  
  <p>Lastly, here is the <code>.htaccess</code> file that cPanel created when I set up the password protection (note: "&lt;USER&gt;" and "&lt;DIR&gt;" have been used for privacy) :</p>
  
  <pre><code>AuthType Basic
  AuthName "Authentication Required"
  AuthUserFile "/home/&lt;USER&gt;/.htpasswds/public_html/&lt;DIR&gt;/passwd"
  require valid-user
  </code></pre>
  
  <p>It's an Apache server, by the way. Many thanks for any advice.</p>