Search code examples
.htaccesspassword-protection

Error 500 protecting a single url with .htpasswd


I tried to implement this code into my .htaccess on wordpress.

Everything works fine but when you get access, it throws an 500 Error and redirects me to my hosting park website. It seems that it doesn't load the content. Not sure if the problem is that the path I'm providing doesn't contain the actual content.

SetEnvIf Request_URI ^/quetecalles require_auth=true

AuthUserFile /kaycho.com/wp-admin/.htpasswrd
AuthName "Password Protected"
AuthType Basic
Order Deny,Allow
Deny from all
Satisfy any
Require valid-user
Allow from env=!require_auth

The snippet is based on this article Error 500 protecting a single url with .htpasswd


Solution

  • AuthUserFile /kaycho.com/wp-admin/.htpasswrd
    

    The file-path to your password file looks incorrect. This needs to be an absolute filesystem-path, not a root relative URL-path (which is what this looks like). If the path is incorrect and the password file cannot be found then you'll get a 500 Internal Server Error response when submitting the username/password.

    Ideally, this should be a file-path outside of your document root directory - that is naturally inaccessible to user requests. It should not be in the same location as the .htaccess file implementing the protection.

    Reference: