.htaccess repeatedly asks for username/password

.htaccess repeatedly asks for username/password - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, , , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


I'm trying to add password protection to my personal website using .htpasswd and .htaccess. When I enter the username and password, I get asked again and again. How do I resolve this?






.htpasswd



st:((encrypted pw))


.htaccess



AuthUserFile /.htpasswd
AuthGroupFile /dev/null
AuthName "Enter Password"
AuthType Basic
require valid-user


Both files are in the root directory. This is the first website I'm building, so I'm no expert.






Edit: I used this tool to create my .htpasswd file.


Solution :


AuthUserFile /.htpasswd

Both files are in the root directory.



The AuthUserFile directive takes an absolute filesystem path (or a path that is relative to the server root), not a path relative to the document root - which is what /.htpasswd looks like? It is unlikely that your "root directory" (by which I assume you mean your website's DocumentRoot) is in the root of your server (if it is then you should probably change it).


You'd expect this to be something like:


AuthUserFile /home/user/secure/.htpasswd

Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect