How can I use .htaccess but avoid a second password prompt when first accessing a sub-directory?

January 13, 2015 584 views

The website is hosted on GoDaddy, and I have a directory protected with .htaccess and .htpasswd. The .htaccess file is located in the protected parent directory, and the .htpasswd file is located in a separate directory. When I navigate to the protected, parent directory, I'm prompted for user ID and password as expected. I enter the ID and password and gain access to the "home" page. If I then select a link on the home page to a different page in a sub-directory of the parent directory, I'm prompted a second time for user ID and password. After entering ID/password a second time, I'm not prompted again for access to any additional pages located in the parent or its sub-directories.

Another curious behavior for these pages is that for some visitors to the site, ALL URLs must use the 'www' prefix. For other visitors, the 'www' prefix is not required for <a...> tags within the pages. I mention this because it may be related.

What am I overlooking in .htaccess that if added would result in "normal" behavior i.e. entering user ID and password for access to the parent directory would allow accessing any sub-directory of the parent without entering ID/password a second time?

Here's the .htaccess file

comment: Private Application

path: /home/content/private/html/57X/

AuthName "57X"
AuthType Basic
AuthUserFile /home/content/r/l/a/rlandman/html/pw/.htpasswd
require valid-user

Thanks for any help you might offer.

1 Answer

It does sound like this is related. My guess based on what you provided is that the site is being accessed in one way (either with or without the www subdomain) but the links on the homepage are using the opposite. For example:

If your site is and you navigate to this page you are prompted for your credentials. Your browser stores these credentials for

If you have a link on your page to you would be prompted again since your browser has not stored any information for the domain, only for

The quickest way to resolve this would be to update your .htaccess files to include a redirect using the apache rewrite module that ensures that any visitor to would then be redirected automatically to

Have another answer? Share your knowledge.