1

I am trying to password protect a website only if it is the dev site using .htaccess and .htpasswd

I am using Apache 2.4.29 on Ubuntu 18.04

Here is what I have in the .htaccess file

<If "%{HTTP_HOST} == 'dev.randy.dev'">
  AuthUserFile "/home/randy/.htpasswd"
  AuthType Basic
  AuthName "dev"
  require valid-user
</If>

I confirmed that the password protection lines do indeed work outside of the IF.

When I try to run the above I get the apache internal server error. I have checked the main apache error.log as well as the virtualhost error log and nothing is being reported in either.

Is it possible to do what I am trying to do or should I go about it another way?

0 Answers0