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$
RewriteRule .* - [E=REMOTE_USER:%{ENV:REDIRECT_REMOTE_USER}]
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?