After setting up a redirect similar to the following in an .htaccess file in a directory, I found that I would get a
500 Internal Server Errorwith the message "The server encountered an internal error or misconfiguration and was unable to complete your request." whenever I tried to access a file in a password-protected subdirectory beneath the one in which I had created the .htaccess file to have the Apache server redirect visitors accessing an old .html file that I had replaced with a .php one.
Redirect 301 /dir1/dir2/example.html /dir1/dir2/example.php
In the Apache error log for the website, I saw the following:
[Wed Mar 19 21:05:17 2014] [alert] [client 192.168.0.10] /home/jdoe/public_html/dir1/dir2/dir3/.htaccess: AuthUserFile not allowed here, referer: http://support.moonpoint.com/dir1/dir2/example.php
That error log entry was created when I clicked on a link I had in example.php to access a file in the directory dir3, which was below the one in which example.php was located.
To allow the redirect to work, I had inserted the following code in
the VirtualHost section for the website within Apache's
The .htaccess file for controlling access to the subdirectory
dir1/dir2/dir3 had worked fine until I created another
.htaccess file above it in dir2 for the redirect. The one for controlling access
to dir3 with a username and password was similar to the following:
Require user test1
Because it contained
AuthGroupFile, but I didn't specify
<Directory> section for the virtual host
httpd.conf file, but only
AllowOverride, the authorization control no longer
worked. When I changed the
AllowOverride line to that
shown below and restarted Apache with
then both the redirect for the file in
dir2 and the HTTP
authentication method for files in the subdirectory
dir2 both worked.
AllowOverride AuthConfig FileInfo
I had forgotten that by limiting
AllowOverride to just
FileInfo for dir2, I was effectively nullifying any other
type of overrides in any subdirectores beneath it.