On my localhost and live website I have different .htaccess directives like this one:
AuthUserFile /path/to/folder/.htpasswd
Is there a way to dynamically indicate the root directory in the .htaccess file so that I don’t need to have different .htaccess files for local vs live hosts?
From: http://httpd.apache.org/docs/2.2/en/mod/mod_authn_file.html#authuserfile :
So one of the solution is to use a relative path. You should use something like
../auth/.htpasswdwith the auth directory outside of your web root (so here for example if the .htaccess is on your web root).PS: %{DOCUMENT_ROOT} is only a mod_rewrite variable AFAIK, so you do not have it for AuthUserFile instruction