Apache: how to set custom 401 error page and save original behaviour

Posted by petRUShka on Server Fault See other posts from Server Fault or by petRUShka
Published on 2012-07-03T17:55:02Z Indexed on 2012/07/05 9:17 UTC
Read the original article Hit count: 357

I have Kerberos-based authentication with Apache/2.2.3 (Linux/SUSE). When user is trying to open some url, browser ask him about domain login and password like in HTTP Basic Auth. If user cancel such request 3 times Apache returns 401 Authorization Required error page. My current virtual host config is

    <Directory /home/user/www/current/public/>
            Options -MultiViews +FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
            AuthType Kerberos
            AuthName "Domain login"
            KrbAuthRealms DOMAIN.COM
            KrbMethodK5Passwd On
            Krb5KeyTab /etc/httpd/httpd.keytab
            require valid-user
    </Directory>

I want to set nice custom 401 error page with some instructions for users. And I added such line in virtual host config:

 ErrorDocument 401 /pages/401

It works, when user can't authorize apache redirects him to my nice page. But Apache doesn't ask user login\password as it did before. I want this functionality and nice error page simultaneously!

Is it possible to make it works properly?

© Server Fault or respective owner

Related posts about apache2

Related posts about httpd