How to use a RELATIVE path with AuthUserFile in htaccess?

后端 未结 9 1397
我在风中等你
我在风中等你 2021-01-31 12:51

I have a .htaccess that uses basic authentication. It seems the path to the .htpasswd file isn\'t relative to the htaccess file, but instead to the server config.

So eve

9条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 13:41

    I know this is an old question, but I just searched for the same thing and probably there are many others searching for a quick, mobile solution. Here is what I finally come up with:

    # We set production environment by default
    SetEnv PROD_ENV 1
    
    
      # If 'DEV_ENV' has been defined, then unset the PROD_ENV
      UnsetEnv PROD_ENV
    
      AuthType Basic
      AuthName "Protected Area"
      AuthUserFile /var/www/foo.local/.htpasswd
      Require valid-user
    
    
    
      AuthType Basic
      AuthName "Protected Area"
      AuthUserFile /home/foo/public_html/.htpasswd
      Require valid-user
    
    

提交回复
热议问题