Jump to content

Recommended Posts

I put a .htaccess file in my root directory containing this:

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /var/www/.htpasswd 
Require valid-user

and it works, but if I wanna upload this site to a server, the path won't be /var/www, and since I don't yet know what the path will be I'm trying to find out how to point to it with explicitly writing the path. In PHP I could do something like:

$path = $_SERVER['DOCUMENT_ROOT'] . '/mysite/.htpasswd';

but I'm new to .htaccess files so I don't know if they have built in variables and functions like that. I tried adding this:

AuthUserFile .htpasswd

but as expected, it looks for a .htpasswd in the current directory which might not be the root directory. I know this from checking the error logs after getting a 500 error.

Apache isn't flexible on the matter, unfortunately.

The AuthUserFile directive sets the name of a textual file containing the list of users and passwords for user authentication. File-path is the path to the user file. If it is not absolute, it is treated as relative to the ServerRoot.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.