kqlambert
kqlambert

Reputation: 2711

.htaccess authentication for directory internal server error

Trying to password protect a directory on my website by using the .htaccess file but I am getting an internal server error after entering my username and password. The directory is located at example.com/admin/

this is the .htaccess file in the admin directory of my site.

AuthType Basic
AuthName "Please enter your username and password"
AuthUserFile /###/admin/.htpasswd
Require user myusername

and the .htpasswd file is in the same directory as the .htaccess file, I have tried changing the AuthUserFile path to just .htpasswd, also tried admin/.htpasswd, but keep coming up with an internal server error

my .htpasswd file looks like this:

myusername:#passwordencrypted#

I am on godaddy hosting if that could be the problem.

Upvotes: 1

Views: 3372

Answers (2)

Joseph Astrahan
Joseph Astrahan

Reputation: 9072

For those SSH & Terminal lovers, you can also log in via SSH and type in pwd to find the full directory to the file. It stands for "print working directory" and will print the directory path to the file all the way from the root.

Upvotes: 0

kqlambert
kqlambert

Reputation: 2711

AuthUserFile /home/###/###/###/html/###/admin/.htpasswd It turns out the actual directory for admin was much more complex then I could have known and I found a useful piece of php which found the path to the .htpasswd file for me at http://www.htaccesstools.com/articles/full-path-to-file-using-php/.

<?php
    $dir = dirname(__FILE__);
    echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>";
?>

Upvotes: 3

Related Questions