In my root directory I have an .htaccess file that redirects non-www traffic to www traffic:
/.htaccess RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule (.*) http://www\.example\.com/$1 [R=301,L]
I am trying to password protect my /admin/ folder and have created its own .htaccess file:
/admin/.htaccess AuthUserFile /path/to/non/public/file/.htpasswd
AuthType Basic
AuthName "Admin"
Require valid-user
The problem is if I go to "example.com/admin/" I get prompted for my password, then redirected to "www.example.com/admin/" where it prompts me for my password a second time.
I'd like to do two things:
1 - Make it so if I go to "example.com/admin/" it first redirects me to "www.example.com/admin/" and then prompt me for my password.
2 - Combine these two .htaccess files in one if possible and advisable.
Any help is greatly appreciated.