How to make a file password protected
You need to use htaccess to make a single file password protected and add these lines in to it.
<FilesMatch file.php>
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
</FilesMatch>
then run command
htpasswd -b .htpasswd username password