I installed apache over windows, and I am trying to use a .htaccess file to password protect a directory. I create my .htpasswd file with the username and the crypted password and I have an .htaccess file like this:

allow from all
AuthType Basic
AuthUserFile c:/home/myweb/cgi-bin/.htpasswd
require valid-user

When I point my browser at http://localhost/ it asks me for the username and password, but it won't accept it. I keep getting an access denied page.

I have tested the same .htpasswd file in an apache server over Linux an it works, what could be the problem with windows?

    A ".htpasswd"-file created on Linux will NEVER WORK IN WINDOWS!!!
    The reason is obvious: there's not the same encryption type. Windows uses MD5 and Linx something else.
    Try again! You might have luck this time!

    Chris

      I tried again using the htpasswd.exe included in the apache distribution, worked like a charm now!! thanks a lot.

        you're welcome. I'm glad to hear that.
        good luck!
        Chris

          10 days later

          hi, ken

          i have installed php3,apache in Window98 and i am looking for the solution same as u( since u have succeed to do it, pls teach me..! thank )

          i have created a .htpasswd file by using htpasswd.exe and i stored the file in:
          C:\Program Files\Apache Group\Apache\users.htpasswd

          i also have created a .htaccess file and put it into one of the directory in document root..

          but i still can access into the directory without any login!
          Please..help me !
          Thank you very much!

          cK

            The .htaccess file need to be in the directory that is password protected. The .htpassword can be anywhere, but you must point to it from the htpasswd

            My document root is
            c:\www\web\htdocs

            In a directory named "private" I placed the .htaccess file, then whenever I want to access that directory it asks me for the username and password. The contents of the htaccess file I have is

            allow from all
            AuthType Basic
            AuthUserFile d:/www/web/htdocs/private/.htpasswd
            AuthName "Private area"
            require valid-user

            and I have the .htpasswd file in the same directory. Hope this example helps.

              7 months later

              I know this is really stupid, but when I try to create any file beginning with a ".", it does not accept it under windows.

              For example I cannot create an ".htaccess" file!!

              Also how do you load that password module?

              Any help will be very much apreciated.

              Thank you very much in advance,
              Fotis

                a year later

                To create a .htaccess or .password file in Windows, make a file called something like "htaccess" and drop to MS-DOS and rename it, e.g. REN htaccess .htaccess

                Works a treat.

                  6 months later

                  OK I have been screwing with this same thing for days, and I can't get it to work. A friend of mine said you have to modify something in http.conf for apache to comprehend .htaccess on Windows. Any ideas?

                    If you put AllowOverride All into the <Directory></Directory> bit in your httpd.conf file, then apache will see the .htaccess file.

                    Chris: This will work with windows as well as linux.

                      Write a Reply...