Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have followed the directions of many tutorials showing how to deny access to a folder in localhost. It looks simple but I can't make it work. I have Apache 2.4 and PHP 7 installed on my windows 10 computer. I have created a number of web pages and they all work as expected with localhost. They are in C:/Apache24/htdocs/.

What I have tried:

create a file .htaccess with the following lines of text.
AuthType Basic
AuthName "restricted area"
AuthUserFile "C:/Apache24/htdocs/protected/.htpasswd"
Require valid-user 
I then entered a user name and password into
http://www.htaccesstools.com/htpasswd-generator/
to generate an encripted password. I pasted the generated password into a second file .htpasswd. I put both ht files into the protected folder. I inserted a .txt file and an .html file into the protected folder to test and see if they were password protected. All of the articles say that to open the protected folder will require username and password to access, but when I type http://localhost in the browser address window it takes me right to the files I want to protect/restrict access to.
Posted
Updated 19-Apr-19 12:33pm
Comments
Peter_in_2780 19-Apr-19 3:54am    
You may be a victim of browser caching. Close the browser (not just the tab) and try again. Once you have entered Basic Auth credentials, the browser will present them every time until you close it.
Member 10628309 19-Apr-19 16:59pm    
I have tried that many times. It has no effect. I think the httpd.conf file needs an edit. Here is what is says now:
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<files ".ht*"="">
Require all denied

1 solution

I am embarrassed to say my problem was...Microsoft Visual C++ Redistributable(64) -14.16.27027.1 was not installed. After installing, everything worked fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900