Where should I put the .htpasswd file?
Posted by: SimonT (---.lightspeed.stlsmo.sbcglobal.net)
Date: July 07, 2023 04:39AM

I've never used password protect for a web site but I seem to just about have it set up. However, I can't get the system to find the .htpasswd file.

The site is in C:\wamp64\www\Psalmonds\jprootfolder. That is the directory the virtual host points at.

I have .htpasswd and .htaccess in the jprootfolder

Where should I put the .htpasswd file?

If I try to put it in the jprootfolder and use (I saw this while searching for info): in the .htacess file

AuthUserFile ./.htpasswd

I get this error in the log:

[Thu Jul 06 21:26:00.503227 2023] [authn_file:error] [pid 2896:tid 852] (OS 2)The system cannot find the file secified. : [client ::1:55319] AH01620: Could not open password file: C:/wamp64/bin/apache/apache2.4.35/.htpasswd

I want the entire site protected. So where do I put the password file and, if I move this site out to a hosting server, what changes would be necessary?

Any assistance will be greatly appreciated.


Options: ReplyQuote
Re: Where should I put the .htpasswd file?
Posted by: Otomatic (Moderator)
Date: July 07, 2023 09:04AM

In one of my local sites, I have a .htaccess and .htpasswd pair to protect access to a folder.

The folder to be protected is: g:\www\phottello\family\marriage_thibaut\
So, in this folder are the two files containing :

File .htaccess
AuthName "Photos avec accés restreint"
AuthType Basic
AuthUserFile "G:/www/phottello/famille/mariage_thibaut/.htpasswd"
require valid-user

and the .htpasswd file contains the user:password pairs:

But all this can be found in the Apache documentation - you just need to do a little research!

Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote

Sorry, only registered users may post in this forum.