保护文件的.htaccess和htpasswd的 [英] Protect a file with .htaccess and .htpasswd

查看:115
本文介绍了保护文件的.htaccess和htpasswd的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦配置.htaccess文件来保护文件的访问。 保护的文件是: www.mydomain.com/admin/stats.php

I'm having some troubles configuring the .htaccess file to protect the access of a file. The file to protect is: www.mydomain.com/admin/stats.php

我把.htaccess文件到www.mydomain.com/admin文件夹下面的code:

I put the .htaccess file into the www.mydomain.com/admin folder with the following code:

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /
<Files stats.php>
require valid-user
</Files>

该文件。htpasswd的是到www.mydomain.com/admin文件夹,也和它包含的用户名和密码。

The file .htpasswd is into the www.mydomain.com/admin folder too and it contains the username and the password.

如果我尝试进入www.mydomain.com/admin/stats.php~~V我得到一个内部服务器错误。我认为错误可以分为的AuthUserFile的路径,但我怎么能告诉文件保护的文件是在htpasswd的同一文件夹?

If I try to access to www.mydomain.com/admin/stats.php I get an "Internal Server Error". I think that the mistake can be into the path of "AuthUserFile" but how can I tell the file that the file to protect is in the same folder of the .htpasswd?

服务器的基于Linux的。

The server is Linux based.

推荐答案

我想你需要把完整路径htpasswd的文件: IE浏览器。

I think you need to put complete path to htpasswd file: Ie.

的AuthUserFile /家庭/ -user - / - 网站 - 。/ htpasswd的

AuthUserFile /home/-user-/-site-/.htpasswd

这篇关于保护文件的.htaccess和htpasswd的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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