I am trying to use a .htaccess file to setup specific behaviors for one directory.

My .htaccess is as follows:

ErrorDocument 401 /var/www/secret/logging.php

AuthName "My Password Protected Site"
AuthUserFile /var/www/secret/.htpasswd
AuthType Basic
Require valid-user

# Set REMOTE_USER env variable on 401 ErrorDocument
RewriteEngine On
RewriteBase /secret/
RewriteCond %{ENV:REDIRECT_STATUS} ^401$

However, when attempting to test this, the Apache default error page states a 404 was encountered while trying to use an ErrorDocument to handle the request. All permissions are correct, all filepaths are correct.

What am I doing wrong?


I think you should try to add an entry like this

<Files /var/www/secret/logging.php>
  Order allow,deny
  Allow from all
  • Why? That wouldn't seem to solve my errordocument issue? – John Sanders Nov 23 '15 at 14:27
  • reading here I'm wondering if the two methods does not conflict with each other. What happen if you try to comment out all the rewrite part? – lese Nov 23 '15 at 15:07
  • I am trying to implement this: serverfault.com/questions/460765/… – John Sanders Nov 24 '15 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.