Problem : When wordpress is installed on main domain and you want to set the password to any directory which is under the public_html folder but when access it by using browser then the URL shows 404 error or not found error.
Solution : You need to add the following code in .htaccess files in which your password protect code is inserted.
ErrorDocument 401 default
That’s it..