Skip to main content
deleted 2 characters in body; edited tags
Source Link
Jeff Schaller
  • 68.9k
  • 35
  • 122
  • 267

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?

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?

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?

Source Link

ErrorDocument not working with .htaccess file

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?