Password Protect a Directory Using .htaccess

This is demo example and we here set credentials as admin for both username and password

1) .HTpasswd

admin:$apr1$/g99U8NQ$KrlCd6rhw5ccarrPKaASu1

"you can generate this code from here :- http://www.htaccesstools.com/htpasswd-generator/"

2) .Htaccess

# -FrontPage-

#AuthType Basic

#AuthName "admin"

#AuthUserFile /mounted-storage/home152/sub025/sc81900-ALDN/videofeed.me/test/.htpasswd

#Require valid-user

#php_value register_globals 1

AuthName "admin"

AuthUserFile "/mounted-storage/home152/sub025/sc81900-ALDN/videofeed.me/test/.htpasswd"

AuthType Basic

require valid-user

3)HOW TO FIND THE FULL PATH TO A FILE USING PHP

<?php
$dir = dirname(__FILE__);
echo "<p>Full path to this dir: " . $dir . "</p>";
echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>";
?>
Advertisements