How to use a RELATIVE path with AuthUserFile in htaccess?

后端 未结 9 1372
我在风中等你
我在风中等你 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:37

    .htpasswd requires full absolute path from the absolute root of the server.

    Please get full absolute path of the file by echo echo $_SERVER['DOCUMENT_ROOT'];.

    here is working basic auth .htaccess script.

    AuthType Basic
    AuthName "Access to the Hidden Files"
    AuthUserFile 'C:/xampp/htdocs/ht/.htpasswd'
    Require valid-user
    

    Before login

    enter image description here

    Afetr Login

    enter image description here

提交回复
热议问题