To protect a folder from your website, you can actually use the htpasswd feature available within the server.
To create a password protected folder to /home/user/public_html/images with user named admin, run the following command.
[root@server ~]# htpasswd -c /home/user/public_html/.htpasswd admin New password: Re-type new password: Adding password for user admin [root@server ~]#
Then, add the following code to your .htaccess file located at your public_html folder.
AuthUserFile /home/user/public_html/.htpasswd AuthName "images" AuthType Basic
Now, access your folder with the given credential.
You can also password protect a file in Linux, check the steps here.