My .htaccess file:
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/www/html/public/.htpasswd
Require user test.user
If I rename the .htaccess file then the site works OK. Otherwise the Beanstalk healthcheck status goes RED, and the site returns a status of 503 (status unavailable).
What's my next step to get this working?
Ryan at AWS said: "There needs to be a publicly accessible URL that Elastic Beanstalk can reach in order for the environment to stay green. This is called the health check URL, and it must return an HTTP status 200."
As a result I created a separate health check URL in a subdirectory which had the authentication turned off, and pointed the Beanstalk health check at this new URL (configure environment Load Balancer tab). The Elastic Beanstalk website is now GREEN.