protect single file in htaccess

by Ramshan 2014-10-16 20:23:38

You can protect a single file in htaccess using the following,

-- First create a file named ".htaccess" and add the following line of code,
AuthName "Only Admin Can Access"
AuthType Basic
AuthUserFile /path/to/.htpasswd
require valid-user

-- Second, create a file named ".htpasswd" and add the username and password as,
user:$apr1$yUfasdxy$712kJrWjFHsRbOLm8sHnl0
Note: Use any password generator tool to create the htpasswd for eg, https://www.hscripts.com/tools/htpasswd/index.php
1411
like
0
dislike
0
mail
flag

You must LOGIN to add comments