0

I am using hostinger hosting,

I have my root folder /public_html and I have added the .htpasswd file in this folder.

I have another folder called /publish_html/demo and I have to protect this folder so I have added the .htaccess file to this folder.

Below is the code I have in .htaccess file

AuthType Basic 
AuthName "My Protected Folder" 
AuthUserFile /public_html/.htpasswd 
require valid-user

And below is the code that I have in .htpasswd file. I have generated from this link

Test:$apr1$6z74iw3s$6P2i3Q1XGquJ/W.K5FIVu1

Now when I check my demo URL then I am getting a popup to add the username and password but every time it's not accepting the details.

Any idea what is the issue? I have checked this on Google but most of the answer saying about the AWS config file. I am using shared hosting.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Naren Verma
  • 2,205
  • 5
  • 38
  • 95
  • 2
    `/public_html` might be _your_ "root" on the system, but the path you specified is absolute due to the leading slash, so this is referring to the _server's_ root directory - and as such, it is most likely a _wrong_ path. You need to specify either the full absolute path, or one relative to your ServerRoot. – CBroe Aug 18 '23 at 06:32
  • @CBroe, in Hostinger, Each domain has there own /public_html folder... and this /public_html is my demo domain only – Naren Verma Aug 18 '23 at 08:18
  • 2
    That doesn't change the fact, that this certainly will not be the root directory of the whole server. https://support.hostinger.com/en/articles/1583494-what-is-the-path-to-your-website-s-root-home-directory-and-how-to-change-it – CBroe Aug 18 '23 at 08:42
  • "every time it's not accepting the details" - What happens exatcly? What HTTP response are you getting? What webserver/version are you using? – MrWhite Aug 18 '23 at 09:30
  • @MrWhite, I am entering the username and password but nothing is working.. it's showing again the same popup. I am using wordpress with the latest version. and using Shared hostinger webserver – Naren Verma Aug 18 '23 at 10:38
  • You should look into the http server's error log file, that is where that served documents explicitly _why_ those credentials did not get accepted. You hosting provider should offer some means to access that information. If not you should switch the hoster, since that information is vital to operating a web service. Apart from that I agree with what @CBroe pointed out above: you need to understand the difference between the root of your virtual web server and its root folder and the whole server system with a single root folder. And you need to adjust the path pointing to your `.htpasswd` file – arkascha Aug 19 '23 at 06:39

0 Answers0