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

  • Posted on January 13, 2015
  • irwin4Asked by irwin4

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. irwin4

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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