Jump to content

Problem in htaccess password protection


sunil_23413

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/175955-problem-in-htaccess-password-protection/
Share on other sites

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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.