http -> https with user authentication

New to mod_rewrite? This is a good place to start.

http -> https with user authentication

Postby Guest » Mon Oct 27, 2003 12:29 am

If been trying to get this working for about 4 days now. I hoping someone in this forum knows how to solve it.....

If someone connects to http://myserver.com/admin I want it to automatically swith to https://myserver.com/admin and promt for a username and password. This should also be the case for all subdirectories of /admin

So far:

If I just use the rewrite rule, it works like a charm:
Code: Select all
<Directory "/www/webroot/admin">
   RewriteEngine On
   RewriteCond %{SERVER_PORT} 80
   RewriteRule .* https://%{HTTP_HOST}:443%{REQUEST_URI} [QSA,R=permanent,L]
</Directory>

If I just use the authentication stuff, it works like a charm:
Code: Select all
<Directory "/www/webroot/admin">
   Options +FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
   Allow from 127.0.0.1
   Allow from 192.168.0.2
   AuthUserFile ../htpasswd/.htpasswd
   AuthGroupFile ../htpasswd/.htgroup
   AuthName "Secure Administration Connection"
   AuthType basic
   require group admins
</Directory>

But if I use a combination of the two, I get prompted to type in the username and password twice!
Code: Select all
<Directory "/www/webroot/admin">
   Options +FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
   Allow from 127.0.0.1
   Allow from 192.168.0.2
   AuthUserFile ../htpasswd/.htpasswd
   AuthGroupFile ../htpasswd/.htgroup
   AuthName "Secure Administration Connection"
   AuthType basic
   require group admins
   RewriteEngine On
   RewriteCond %{SERVER_PORT} 80
   RewriteRule .* https://%{HTTP_HOST}:443%{REQUEST_URI} [QSA,R=permanent,L]
</Directory>

How can I solve this? It there a better way to do this? :-?
Guest
 

Postby ufo » Mon Oct 27, 2003 12:32 am

Sorry, forgot to login to the forum.... :silly:
ufo
 
Posts: 1
Joined: Mon Oct 27, 2003 12:13 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

cron