sunil_23413 Posted September 29, 2009 Share Posted September 29, 2009 I want to apply htaccess password protection to one of my my site http://manjotone.freehostia.com . When I go to above url it demands a username/password. Even if I fill correct username/password (test/test) it still does not show the site and the login box appears each time whether I fill correct or wrong username/password. How can I resolve this issue? The content of htaccess file is AuthName "Restricted Area" AuthType Basic AuthUserFile /home/www/manjotone.freehostia.com/.htpasswd AuthGroupFile /dev/null require valid-user And the content of htpasswd file is test:VKDgrEqD7TJBM I simply upload these files through FTP where my site exists .please suggest me what should I do to overcome this issue. Quote Link to comment https://forums.phpfreaks.com/topic/175955-problem-in-htaccess-password-protection/ Share on other sites More sharing options...
thebadbad Posted September 29, 2009 Share Posted September 29, 2009 Apache supports three types of password hashes: Crypt, MD5 and SHA-1. The hashes of test to be used in a .htpasswd file are 6m1Ebu8dvl8Wg $apr1$6mSgt...$rrO6wgJSTrA7ZtXmLqaaj1 {SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M= respectively. Try one of those instead of the (wrong) one you have. Quote Link to comment https://forums.phpfreaks.com/topic/175955-problem-in-htaccess-password-protection/#findComment-927163 Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2009 Share Posted September 29, 2009 The first two characters of the Crypt password is a random salt, so both the OP's and your value could be correct for the same password. The two character salt from the hashed value is used when the entered value is hashed and will result in the same hash value if the password is the same as the original. Edit: Tested - <?php $user_input = 'test'; $hash = 'VKDgrEqD7TJBM'; if (crypt($user_input, $hash) == $hash) { echo "Password $hash verified!<br />"; } $hash = '6m1Ebu8dvl8Wg'; if (crypt($user_input, $hash) == $hash) { echo "Password $hash verified!<br />"; } ?> Password VKDgrEqD7TJBM verified! Password 6m1Ebu8dvl8Wg verified! Quote Link to comment https://forums.phpfreaks.com/topic/175955-problem-in-htaccess-password-protection/#findComment-927177 Share on other sites More sharing options...
thebadbad Posted September 29, 2009 Share Posted September 29, 2009 Ah, thanks. Don't know what's wrong with the OP's code then. Quote Link to comment https://forums.phpfreaks.com/topic/175955-problem-in-htaccess-password-protection/#findComment-927195 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.