Some times we need to protect our site from public users and make it available only to selected number of users. For examply you might want to protect your alpha site from the public and from search engine bots. In such situations we protect our site with HTTP password. Follow the below steps for protecting your Drupal site with HTTP password. This was written for an Amazon AWS server but should work on most GNU/Linux servers.
- Run the htpasswd utility
$ sudo /opt/bitnami/apache2/bin/htpasswd -c /opt/bitnami/apache2/httpd-auth username $ cd /opt/bitnami/apps $ sudo vi virtualhost
- Add the following to virtualhost.conf, between <Directory> and </Directory>
AuthType Basic AuthName yourapplication AuthUserFile "/opt/bitnami/apps/httpd-auth" Require valid-user
- Restart apache2
$ sudo /opt/bitnami/ctlscript.sh restart
Now your Drupal site should be protected using basic authentication which should keep it away from spying eyes and all search engine crawlers. It is standard practice to keep your development, staging and testing environments under basic authentication to prevent search engines crawling them and marking them as duplicate content of your main site.