Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.