tags:

views:

22

answers:

1
+1  Q: 

.htpasswd Problems

I have setup an .htaccess and .htpasswd file correctly and my password gets accepted, but only on the second attempt. I have read somewhere what to do about this, but I lost the page. Any suggestions?

+1  A: 

This is probably because you refer to the domain differently in several locations. For example, if you refer to your site as "http://mysite.com" and "http://www.mysite.com", you have to authenticate twice: once for each. If you refer to your site consistently in your code, you'll only be prompted once.

In addition, if you refer to any subdomains, such as "http://es.mysite.com" for a localized version of the site, you'd have to authenticate again for that reference.

Shaun
Would it then make a difference if my .htaccess page telling it to authenticate was in a subdomain?
William Hand
Also check the path. If you first authenticate at `http://www.example.com/somedir/thing`, the browser will only remember the credentials for other paths inside the `somedir` folder.
bobince
@William Hand: If you are authenticating on a sub-domain but your code has hard-coded references to the main site rather than relative references to the current sub-domain, you'd receive multiple prompts as well.
Shaun