http验证

本文介绍如何在Windows环境下使用Apache服务器配置.htaccess文件进行密码保护。文章详细讲解了设置步骤,包括修改httpd.conf文件、创建密码文件及.htaccess文件的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://sniptools.com/vault/windows-apache-and-htaccess-authentication

Windows, Apache and .htaccess authentication

It is quite sim­ple to use .htac­cess on Win­dows. Sim­ple instruc­tions with screen­shots here.

Enabling pass­word authen­ti­ca­tion on Win­dows using Apache (and here's a link if you wish to RTFM) given the knowl­edge that you are busy folks so these are merely quick instruc­tions to get it work­ing on Windows.

Some things to know beforehand:

  1. Path to your Apache server (e.g., c:apache)
  2. Path to your CONF folder (e.g., c:apacheconf)
  3. Path to your DOCROOT folder (e.g., c:apachehtdocs)
  4. Path to the folder you wish to password-protect. In my
    exam­ple, lets take a folder called "secure", so the path to this
    would be "c:apachehtdocssecure". (It could be ABOVE the htdocs
    folder as well, FYI).

Ok, let the show begin:

  1. Open up your httpd.conf. (On my machine this is at
    "c:apacheconfhttpd.conf").
  2. Look for the word called "Access­File­Name". I believe there
    should be a line like this:

    AccessFileName .htaccess
    

  3. If you use Win­dows 2000 or above, then move on to step 4
    (because you can cre­ate files like ".htac­cess" on your sys­tem which
    do not have any­thing before the dot in the file­name. If not, then
    change this line to the following:

    AccessFileName ht.acl .htaccess
    
  4. Then, we need to add the direc­tory to the con­fig­u­ra­tion.
    Instead of rat­tling on about how to do it, here is a
    screenshot:

    <img src="http://sniptools.com/av/s1.gif" width="679" height="419"
    alt="This is what the HTTPD.CONF should look like. " />

    Please note that "/apache" in the direc­tory path means that it
    starts from the root drive on my machine ("c:"). Adjust
    accordingly.

  5. Our httpd.conf is done. Now we need to cre­ate the pass­word
    file. Open up a DOS prompt and go to the apache's BIN direc­tory. In
    my case, it is "c:apachebin". Any­way, again, I think a screen­shot
    is more helpful.

    <img src="http://sniptools.com/av/s3.gif" width="839" height="904"
    alt="Instructions for cre­at­ing the pass­word file" />

  6. Now, we need to cre­ate the HTACCESS file itself. As per point 3
    above, either cre­ate a ".htac­cess" or a "ht.acl", whichever suits
    you fine. I will keep my exam­ple to "ht.acl" because this works on
    ALL win­dows sys­tems if they use Apache 1.12…or above. Here is
    what this looks like.

    c:apachehtdocssecureht.acl
    

  7. Save the above file into your SECURE folder because it
    rep­re­sents only that folder context.

READY TO ROLL! (I restarted my Apache, just in case). Here is
what hap­pens when I try to access my folder from the browser:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值