在htaccess 中,我想这么写AuthType Basic
AuthName "ABC-Group"
AuthUserFile /usr/www/CCC/public_html/nopublic/.htpasswd
require user zhangsan我想设的密码是abcde
请问在htpasswd中我该怎么写?谢谢。

解决方案 »

  1.   

    在apache/bin/下面有一个程序 htpasswd你google一下相关的资料就知道应该怎么写了。
      

  2.   

    這個是apache的內容吧 網上抄一個給你 
    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"参数去掉就行了,否则就会删除之前的信息.
      

  3.   

    不是,这是我的php里的
    我只想对nopublic目录加密。没有搞定在bin目录下什么都没有。
      

  4.   

    # set password for youhtpasswd -c /usr/www/CCC/public_html/nopublic/.htpasswd abcde
    这个样子就可以了,试一下吧。
      

  5.   

    以前做过类似的设置,不过好久没有玩了。你在学习linux么?
      

  6.   

    谢谢,搞定了htpasswd -c /usr/www/CCC/public_html/nopublic/.htpasswd zhangsan
    就可以了我现在就是用用ubuntu。就是tex部分texmaker和Kile没有ctex做的好,不能用skype,因为话筒功能失效。其他ubuntu用的还是很爽的。