You definitely should NOT put an exception for the .htpasswd
file. This file is never served over the web. It is read by the web browser, but it should never be served as a file to any random stranger. Adding an exception for it does not make any difference on whether your site is password-protected or not. It only controls whether any random person on the Internet can download the file containing the (plaintext) username and (weakly) hashed password, which would allow them to crack that very weak hashing, therefore view your site if they so wished.
The reason you experience it as the protection “not taking place” is that your browser remembers the login credentials for the site and sends them with your request. This is true even if you use the private browsing / incognito mode of your browser (yeah, I know, right?!!). You can use a different browser you don't normally use, e.g. Chromium, making sure you have cleared all stored data.
I did not realize that Google could no longer access this file and it was not indexing my pages of the site that I had just put online. By putting this exception it seems to work. Is there anything else for Google?
The code you asked me about adding to the .htaccess file puts your entire site behind a username and password. Nobody can access anything on the site unless they provide the correct username and password combination. This concept is antithetical to indexing your site. You said so yourself when you described it as “I used a protection against robots indexation” [sic]. Yes, this code prevents any robot from indexing your site, including Google Bot which is used by all of Google's services.
So, the question is, was that your intention or not? You can't be hiding your site from everyone by using a username and password to access it, and expect it to be indexed at the same time. Do you want it hidden or not?
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!