In my httpd.conf file, under one of my virtual hosts, I have the / directory password protected using http basic auth. If a user doesn't enter a valid username/password combo, I would like to display a custom error document to them, telling them to signup to my site. Unfortunately when using "ErrorDocument 401 /noaccess.html" the noaccess.html (according to my error.log file) must be a file accessible via the current virtual host.
Since the / directory is protected, and /noaccess.html is within that directory it is also protected and I just receive Apache's standard 401 error, with an additional message on the bottom saying the 401 page is also returning 401.
Here is the (relevant) config:
<Virtualhost my.hostname.com>
<Location />
PerlAuthenHandler Apache::SecureCheck
AuthType Basic
AuthName MyDomain
require valid-user
</Location>
<Location /noaccess.html>
allow from all
</Location>
ErrorDocument 401 /noaccess.html
</VirtualHost>
I have shuffled around the order of the two <Location> blocks and the Error 401 tag, with no luck.
Also, if possible, i'd like to have noaccess.html located on a different virtual host, or even in a non-web accessible directory. Currently I am hoping to accomplish this via
Alias /noaccess.html /home/me/noaccess.html
However, I have tried removing the alias command, and using an actual file with no luck displaying the noaccess.html file.
Thanks
Start Free Trial