I believe you have the same problem as I had with my wordpress website.
I had a WordPress website where I want to password protect a folder using .htaccess if yes try the following solution:
open .htaccess from your root (public_html) folder and add the following code at the top of the file
ErrorDocument 401 default