First, create a .htaccess file in your public_html to protect the entire site or specific directory, and add the following content in the .htacces file:
Code: Select all
AuthType Basic
AuthName "Please login"
AuthUserFile /home/myuser/web/yourdomain.com/public_html/.htpasswd
require valid-user
Now, let's create the .htpasswd file
The first option is to generate the content of that file online, for example, here - https://www.web2generators.com/apache-t ... -generator
Copy-paste the output (you got from that site) to the .htpasswd file, and upload that file to /home/myuser/web/yourdomain.com/public_html/.htpasswd
That's it, you secured a site/folder.
If you don't want an online tool to generate a .htpasswd file, the second option is to generate a .htpasswd file via SSH:
Code: Select all
htpasswd -c /home/myuser/web/yourdomain.com/public_html/.htpasswd myuser
If you also want to secure static files (like images)
Go to myVesta, into the WEB section, EDIT your domain, and in Proxy Extensions delete everything and leave only, for example, css and js:
Save modification.
This way, you will pass all requests (except for css and js) to Apache, which will then request HTTP authentication from the visitors.