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?