.htaccess file modifies apache settings based on the file system location, where you want to change settings based on the virtual host context.
So instead of setting up authentication in the .htaccess file, modify the Apache configuration file and add authentication settings to the correct virtual host entry:
AuthName "authenticated Users Only"
Instead of using a
<Directory /some/path/public_html> directive this could also be good use-case for
<Location /public_html> directive within the virtual host context.
On a side note the strong recommendation from the Apache project with regards to
You should avoid using
.htaccess files completely if you have access
to httpd main server config file. Using
.htaccess files slows down
your Apache http server. Any directive that you can include in a
.htaccess file is better set in a Directory block, as it will have the
same effect with better performance.