PDA

View Full Version : Password protecting a directory. Have to enter user/password twice?


NeilFawcett
5-31-05, 06:36 AM
I used sitemanager to password protect my webstats directory.

What I'm confused about is the fact when I go the directory I have to enter my username & password twice. ie: It pops up the user/password to enter and I do that, then it asks me again. Only after I enter the details for a second time do I then finally get into the directory.

This is both IE6 and Firefox...

RTH10260
5-31-05, 09:00 AM
I used sitemanager to password protect my webstats directory.

What I'm confused about is the fact when I go the directory I have to enter my username & password twice. ie: It pops up the user/password to enter and I do that, then it asks me again. Only after I enter the details for a second time do I then finally get into the directory.

This is both IE6 and Firefox...I seem to remember that this effect happens when one enters a directory without ending the URL with a slash. The first password prompt comes from accessing the directory as a file (with no extension). then a second from accesing the default index.html/.php file. Use htaccess to rewrite the URL to add a trailing slash if necessary.

extras
5-31-05, 09:09 AM
Sounds like the common phenomena of the URL of a directory without trailing slashe.

Easiest fix: Always add slashe to the URL if it's a directory.
Otherwise you are also creating another hit, on top of 401 responses.

You can use RewriteRule to stop this, too.
But it prevent only double login problem, and it will still create 301 (or 302( redirect.
Also, you may have to asjust the code depending on your current RewriteRules.

Yhis code seems to satisfy most people

# Trailing slashe correction (for solving 'www' dropping and double login problem)
RewriteCond s%{HTTPS} ^((s)on|s.*)$
RewriteRule ^/*(.+/)?([^.]*[^/])$ http%2://%{HTTP_HOST}/$1$2/ [L,R=301]


See this link for details.
300604

NeilFawcett
6-1-05, 05:03 AM
Spot on! Thanks!