Good day! I am trying to configure Apache authentication using Basic to get started. I have shared hosting at my disposal, on which I cannot manage the settings of the web server. I prepared a file on the "home" Apache web server (running under Windows) an identifier: a password and put it in the same directory that I want to protect against access using .htaccess . I know that the Apache manual categorically does not recommend doing just that, but nevertheless this option so far suits me. "Research" showed that the password file is searched for in the Apache "home" directory, where I do not have access to the hosting. Therefore, I want to ask how to set the AuthUserFile file.txt parameter so that file.txt is taken from the current directory?


AuthType Basic AuthName "admin area" AuthUserFile d:\web\htdocs\test\file.txt Require valid-user 

    1 answer 1

    First of all, the password file is not searched for in the Apache home directory, but, with a relative path, as a path, relative to the ServerRoot directive.

    Secondly - in the directive AuthUserFile you need to specify the absolute path to the file file.txt . In your case, if the required file is in the admin directory, then the full path will end with public_html/admin/file.txt . But what will be there at the beginning - you need to check with those. support your hosting. Tell them that you need to know the full path to the file - they will prompt. Or, if you have SSH access to the hosting, connect and execute the pwd - it will write the full path to the current directory. From it already build the path to the file you need.

    • To @ MAN69K Thank you, there are shifts, but 1) It gives an error AH01630: client denied by server configuration . Googling and adding Require all for does not help. The contents of the directory browser sees. ((2) How to register the file location on the hosting, if, suppose, the directory for the public_html files and it has the admin folder - Apron63
    • @ Apron63: on the first error - complete your initial question with the contents of the .htaccess file. Regarding the catalog - added your answer. - MANKK