To password protect a directory do the following.
First log into the hosting space using the command line. Once logged in run the following and record the required information.
pwd <– get the full path of the current directory, this is the [PATH]
Example output would be : /var/www/www.sogoth.com/web
Now run the following command:
htpasswd -c .htpasswd [username]
[username] is just a login name for 1 of the accounts you wish to access the password protected folder. You can have multiple users, but must run the command once for each user.
Example :
htpasswd -c .htpasswd exampleuser
New password:
Re-type new password:
Once complete go to the folder you wish to protect and create a new file .htaccess.
In this file add the following:
AuthUserFile [PATH].htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic
<Limit GET POST>
require user [username]
</Limit>
For my example it would be:
AuthUserFile /var/www/www.sogoth.com/web/.htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic
<Limit GET POST>
require user exampleuser
</Limit>
Now visit the website location and you should have a login screen. Type in the username and password and you should have access.
if you found this helpful feel free to donate to:
ZEC: | t1NQp1UuqQbmnXzazbLTSreS2AbaZpRBuTM |
LTC: | LZyNF1qkBUA7XFz83m5xwzGgmmj1owQn9d |
BTC: | 1PY95KFPTEJTR7f2NnSgaB6xB9pwDJkcJz |