.htaccess tutorial

htaccess Elite


Require SSL before asking for htaccess password!

SSL, TLS related

Require SSL before asking for htaccess password!

Postby produke » 27 Sep 2006 07:10

This code redirects http://secure.example.com/login.php to https://secure.example.com/login.php BEFORE it prompts you for your htaccess password.

This is if the htaccess file is in the / folder where login.php resides.

What is happening is that when a user makes a non-SSL encrypted request in the / folder, the SSLRequireSSL directive issues a 403 Error back, then the ErrorDocument redirects to the https page and THEN the htaccess password prompt appears.

This gets rid of the double-login double prompts for htaccess passwords that occur when the domain is different.

Code: Select all
SSLRequireSSL
ErrorDocument 403 https://secure.example.com/login.php

AuthUserFile /wwwroot/.htpasswd
AuthGroupFile /dev/null
AuthName "webmail"
AuthType basic
require valid-user
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

Return to SSL