Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have password-protected the root folder of my website while i do maintenance, but I want to display a custom 401 error page to let people know the site is under construction. Unfortunately, my web host doesn't allow me write access to anything outside the root folder of my website, so this custom error page must by stored in the root folder or one of its subfolders. Instead of my custom error page I get the Apache default error page and it also says "Additionally, a 401 Authorization Required error was encountered while trying to use an ErrorDocument to handle the request."

I searched for ways to make a subfolder of a protected directory public, and all I could find was to use the "Satisfy any" directive, but this doesn't work for me. It doesn't work on a file-only basis either, as with the .htaccess file below.

#Authorization Restriction
AuthType Basic
AuthName "Access to root"
AuthUserFile *********************************
Require user ***********

Order Allow,Deny

Satisfy any

#Error Documents
ErrorDocument 401 Error-401.html

#Allow access to error documents
<Files Error-*,html>
Order Deny,Allow
Allow from all
Satisfy any
</Files>

I can only use .htaccess files; I don't have access to httpd.conf

share|improve this question
add comment

1 Answer

It's working for me. But you have a typo in <Files Error-*,html> instead of the comma should be dot: <Files Error-*.html>

On my localhost it works even without Files Directive. But on production server I had to use Satisfy any as you suggest.


You can place your custom 401 error directly into ErrorDocument:

ErrorDocument 401 "<html>...</html>"

Or you can envelope your Auth rules with <FilesMatch> and only negate the 401.html file:

<FilesMatch "^(?!401\.html$).+">
AuthType Basic
AuthName "Awe!"
AuthUserFile /full/path/to/.htpasswd
require user Lord
</FilesMatch>

ErrorDocument 401 /401.html
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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