在htaccess 中,我想这么写AuthType Basic
AuthName "ABC-Group"
AuthUserFile /usr/www/CCC/public_html/nopublic/.htpasswd
require user zhangsan
我想设的密码是abcde
请问在htpasswd中我该怎么写?谢谢。
AuthName "ABC-Group"
AuthUserFile /usr/www/CCC/public_html/nopublic/.htpasswd
require user zhangsan
我想设的密码是abcde
请问在htpasswd中我该怎么写?谢谢。
解决方案 »
- 请教关于pdo的prepare用法
- 用phpmyadmin查看,记录数和大小都是unknown,是怎么回事?
- 写了个遍历目录、批量替换文件内容的类
- 弹出窗口的问题,有没有办法,让弹出的窗口右上角没有最小化、最大化、关闭三个按钮?呢
- SNS获取邮箱联系人列表的PHP代码(最好有hotmail,gmail,yahoo)
- 谁能推荐一个颜色取色器
- 怎么让php5 支持 mssql2000》?
- 使用sybase的php页面奇怪问题!!!
- 如何讓checkbox獲取數據庫的值?根據值讓checkbox處於選擇狀態或者未勾選狀態
- 怎么获得一个文件的绝对路径?
- php做后台,怎么和前台结合?
- PHP的FTP函数
http://motus.blog.51cto.com/78324/99192前些天在网上溜达,遇到一个网站需要口令才能登录,我很感兴趣.故又去翻APACHE的文档了解下,终于我也弄出一个需要口令认证的网站,故写下笔记分享下~
APACHE的安装就另搜索吧,不在此再写了.下面来看下HTTPD.CONF文档,默认的文档里有这么一段话
------------------------------------------------------------------------------------------------------------------------
.......
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
......
-----------------------------------------------------------------------------------------------------------------------------
其中有一行:
AllowOverride None
AllowOverride为何物?有何用?下面我们来看下官方文档的解释:
AllowOverride 指令
说明 确定允许存在于.htaccess文件中的指令类型
语法 AllowOverride All|None|directive-type [directive-type] ...
默认值 AllowOverride All
作用域 directory
状态 核心(C)
模块 core
.htaccess文件(或者"分布式配置文件")提供了针对每个目录改变配置的方法,即在一个特定的目录中放置一个包含指令的文件,其中的指令作用于此目录及其所有子目录。
OK,也就是说,可以在某一目录下配置.htaccess文件,然后通过AllowOverride 开关,我们就可以创建一个口令认证的网站了
这里我以网站的根目录为例,如下
<Directory />
AllowOverride all //启用.htaccess
AuthType Basic //Basic认证方法,明文传送
AuthName "my web" //服务器标识
AuthUserFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/passwds" //密码文件
Require valid-user //允许所有用户访问
</Directory>
下面要配置密码文件C:/Program Files/Apache Software Foundation/Apache2.2/conf/passwds
这个文档可通过记事本录入,格式为[username]:[password];也可通过bin下的一个htpasswd.exe小程序生成的,可支持MD5,CRYPT和SHA三种方式加密.下面就用htpasswd.exe创建一个帐号C:\Program Files\Apache Software Foundation\Apache2.2\bin\htpasswd.exe -c "C:/Program Files/Apache Software Foundation/Apache2.2/conf/passwds" motu
Automatically using MD5 format.
New password: ***
Re-type new password: ***
Adding password for user motu
//创建C:/Program Files/Apache Software Foundation/Apache2.2/conf/passwds文档,用户名是motu,默认启用MD5加密.
当你需要创建第二个用户时,只要将"-c"参数去掉就行了,否则就会删除之前的信息.
我只想对nopublic目录加密。
bin里面什么也没有