如何拒绝访问localhost中的文件夹 [英] How do I deny access to a folder in localhost

查看:147
本文介绍了如何拒绝访问localhost中的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照许多教程的说明,显示了如何拒绝访问localhost中的文件夹。它看起来很简单,但我不能使它工作。我在我的Windows 10计算机上安装了Apache 2.4和PHP 7。我创建了许多网页,它们都可以按照预期的方式使用localhost。他们在C:/ Apache24 / htdocs /。



我尝试过:



使用以下文本行创建文件.htaccess。

 AuthType Basic 
AuthName受限区域
AuthUserFileC:/Apache24/htdocs/protected/.htpasswd
需要有效用户

然后我在

 http://www.htaccesstools.com/htpasswd-generator/ 

中输入用户名和密码以生成入站密码。我将生成的密码粘贴到第二个文件.htpasswd中。我将两个ht文件放入受保护的文件夹中。我将.txt文件和.html文件插入受保护的文件夹中进行测试,看看它们是否受密码保护。所有文章都说要打开受保护的文件夹需要用户名和密码才能访问,但是当我在浏览器地址窗口中键入http:// localhost时,我需要使用我想要保护/限制访问的文件。 div class =h2_lin>解决方案

我很尴尬地说我的问题是...没有安装Microsoft Visual C ++ Redistributable(64)-14.16.27027.1。安装完成后,一切正常。


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.

解决方案

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.


这篇关于如何拒绝访问localhost中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆