htaccess doesn't work - always wrong password

前端 未结 9 2323
盖世英雄少女心
盖世英雄少女心 2020-12-15 04:04

I am trying to password protect a directory, and have two files in the directory which should password protected it:

  • .htaccess
  • .htpasswd
<
相关标签:
9条回答
  • 2020-12-15 04:39

    Also, make sure your password file is ANSI-encoded.

    0 讨论(0)
  • 2020-12-15 04:39

    I spent about 2 hours to resolve the same issue. But problem was in nginx. I have nginx as front web server and there was a line for proxy configuration:

    proxy_set_header Authorization "";

    It overrides Authorization field and apache don't receive login and password typed in.

    I just commented out this line and it worked.

    0 讨论(0)
  • 2020-12-15 04:40

    I had a similar issue using MAMP and it was because i was creating .htpasswd by hand. Solution was to use htpasswd command in terminal:

    htpasswd -bc .htpasswd someuser somepass
    

    this created the .htpasswd file which worked fine with my .htaccess file which looked like so:

    AuthType Basic
    AuthName "This site is in alpha and requires a password."
    AuthUserFile "/Applications/MAMP/htdocs/mywebsite/.htpasswd"
    require valid-user
    
    0 讨论(0)
提交回复
热议问题