Hallo,

i have some problems using htaccess on my windows machine.

Please notice it works on remote (linux)

this is my .htaccess file:

AuthName "Protected Area"
AuthType Basic
AuthUserFile C:/Inetpub/wwwroot/.htpasswd
require valid-user

I use "crypt" for the passwort.

If I try to enter the protected area I get the popup then I entering the login data and access dinied.

I read something on Internet that it have to work on Windows 2K prof.

    .htaccess doesn't work on Windows.

    you will have to make changes in your http.conf of Apache.

    to protec a file you can use:

    <Files "c:/complete/path/to/file/">
    AuthName "Protected Area"
    AuthType Basic
    AuthUserFile C:/Inetpub/wwwroot/.htpasswd
    require valid-user
    </Files>

    for protecting complete directory you may use
    <Directory "c:/complete/path/to/directory">
    AuthName "Protected Area"
    AuthType Basic
    AuthUserFile C:/Inetpub/wwwroot/.htpasswd
    require valid-user
    </Directory>

      Thanks for your response...

      That will mean i don't need the htaccess files?

      What about all this postings about htaccess configurations (for windows) on the net?

      For the single file protection:

      that means i can protect on single like:

      path/to/file/secret.pdf

        I still have a problem while using this features maybe its something wrong how i create the password File?

        if (isset($Submit)) {
        	$filehandle = fopen(".htpasswd", "w");
        
        $pass = crypt($newpass);
        $pwfilecontent = $login.":".$pass."\n";
        
        fputs ($filehandle, $pwfilecontent);
        fclose($filehandle);
        }
        

        By the way the problem looks like the same like using the .htaccess file.

          in windows you cannot have file names starting with period (.)
          hence u must either rename the file in DOS, or
          make a file name as htpasswd instead on .htpasswd and provide path to that file instead. it will be good to keep that file outside the web root

            Hallo,

            it looks not like a problem with the filename...
            Is it it possible that windiows don't understand the password created with "crypt"?

              Originally posted by jayant
              in windows you cannot have file names starting with period (.)

              Sorry Jayant, I beg to differ. I have run Apache on a windows machine and I have been able to use .htaccess files with no problem.

              Olaf, take a look at this tutorial. I can't remember where you find the password utility htpasswd, but do a search for it on your system.

                Hallo,

                Thank your for this link. I have read a lot about this things but i think that my only problem is the password-encryption. They write something about MD5. I like "crypt", this works on Linux.

                Is here some who use his own script for creating passwords?
                (don't like the dos-box)

                  Sorry, but i asked about the use of the php-function "crypt"

                    I use htaccess files all the time on both Win ME and Win XP (Home & Pro). Never had any problems.

                    ---tom

                      Hallo,

                      i have it workin ( i have used th htpasswd.exe).

                      But why is it wrong to do this with my script what i posted before?

                      This script works well for Linux.

                        Originally posted by piersk
                        Sorry Jayant, I beg to differ. I have run Apache on a windows machine and I have been able to use .htaccess files with no problem.

                        Olaf, take a look at this tutorial. I can't remember where you find the password utility htpasswd, but do a search for it on your system.

                        doesnt work on win98 w/ apache 1.3.26 . so i guessed maybe not with other as well. ya i know i should be using apache2 on windows 😃

                          Originally posted by piersk
                          Sorry Jayant, I beg to differ. I have run Apache on a windows machine and I have been able to use .htaccess files with no problem.

                          Olaf, take a look at this tutorial. I can't remember where you find the password utility htpasswd, but do a search for it on your system.

                          doesnt work on win98 w/ apache 1.3.26 . so i guessed maybe not with other as well. ya i know i should be using apache2 on windows 😃

                            Hallo,

                            my configuration:
                            W2K sp4 (intel p4)
                            Apache 1.3.28
                            PHP 4.3.3

                            I repeat: why i can't use my own script on this configuration?

                            Does anyone konw?

                              a month later

                              Windows doesn't support encrypted passwords, so your .htpasswd file has to contain your password in plain text

                              Example .htpasswd file

                              yourUsername:yourPassword

                                Yes it does. I've used this before and the password was encrypted.

                                  13 days later

                                  Whilst we're on the topic I might aswell post the problem I'm having. I've read heaps of articles and people say authentication can be done on windows but im yet to find out.

                                  This is in the httpd.conf file:

                                  <Directory "C:/Program Files/Apache Group/Apache2/htdocs">
                                  Options Indexes FollowSymLinks
                                  AuthUserFile "C:/Program Files/Apache Group/Apache2/htdocs/.htpasswd"
                                  AuthGroupFile /dev/null
                                  AuthName "Private"
                                  AuthType Basic
                                  Require valid-user

                                  AllowOverride All
                                  Order allow,deny
                                  Allow from all

                                  </Directory>

                                  my htpasswd file looks like this:

                                  admin:$apr1$Gr1.....$2vsoPuNxjmBmgasIJUONt0

                                  which is admin:test in plain text

                                  now the problem I'm having is that it doesn't seem to pick up I've even got anything there. I'm sure it must be in the code because I've closed my browser and reset apache after every change before testing to see if it works and it doesn't.

                                  I've got apache2 installed and on a winxp pro machine.

                                  Thanks for any help you guys can dish out 🙂

                                    Have any of you tried any of this?

                                    I've used the PHP_AUTH_USER and PHP_AUTH_PW before and that worked quite nicely.

                                      2 years later

                                      hi...

                                      I hav created a .htaccess file for my website. We had no htaccess file before that so i made the new one. This file is just for the redirection purpose and nothing else.

                                      Now the problem is that this file is not working. I create the file as htaccesss.txt and uploaded it on the root directory where all webpages of site r stored....
                                      we have a windows based server.

                                      Then renamed file using ftp command prompt as .htacccess.

                                      even afer all this the redirection is not activated. i want to redirect the old pages of my site to the new one as the old ones r givin 404 error code.

                                      File is like this....

                                      redirect 301 /product.html http://www.syncex.com/products.htm
                                      redirect 301 /download.html http://www.syncex.com/registration.jsp

                                      if anyone knows wat to do then plz lemme know asap...its very urgent

                                        Write a Reply...