CrimpJiggler Posted March 22, 2014 Share Posted March 22, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287183-htaccess-files-how-to-point-to-password-file/ Share on other sites More sharing options...
requinix Posted March 23, 2014 Share Posted March 23, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287183-htaccess-files-how-to-point-to-password-file/#findComment-1473570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.