So I’d like to password protect my directory /admin/ so I put a .htaccess in the /admin/ folder with all the proper info to find the htpasswd file.
The only problem is that when I try to navigate to a file in that directory, it loads and loads and never prompts me for a password, and eventually just times out.
I think this is due to the fact that I have a rewrite condition in my public_html .htaccess file. It’s set up so that any time someone goes to mydomain.com/theirusername it will redirect to mydomain.com/profile/user.php?username=theirusername.
Is there any way to override this so this specific directory will prompt me for my password?
Here is the current code in my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ profile/user.php?name=$0
This is the .htaccess in the /admin folder:
AuthUserFile "/home/passwords/passwd"
AuthName "Please Log In"
AuthType Basic
require valid-user
You are right about: rewrite condition in your
public_html.htaccessfile.Do the following: