Apache .htaccess variable for root directory?
On my localhost and live website I have different .htaccess directives like this one:
AuthUserFile /path/to/folder/.htpasswd
Is there a way to dynamic开发者_JS百科ally 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 :
File-path is the path to the user file. If it is not absolute, it is treated as relative to the ServerRoot.
So one of the solution is to use a relative path. You should use something like ../auth/.htpasswd
with 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
精彩评论