Forum Moderators: phranque
AuthUserFile "/home/sites/myusername/httpdocs/.htpasswd" Now, by using this absolute path, the site cannot easily be moved to another account or even another server or hoster without changing stuff manually, because the above path won't be valid there. I'd have to manually inspect all .htaccess files in the entire site, and change the paths accordingly.
Therefore, I'd prefer to use something like:
AuthUserFile "./.htpasswd" or
AuthUserFile "./httpdocs/.htpasswd" or
AuthUserFile "%{DOCUMENT_ROOT}/.htpasswd" or whatever would be relative to my site's local folder. But I can't get this to work.
Is this actually possible, or does .htaccess really ONLY allow absolute paths? The apache mod_auth manual says otherwise, but it says 'relative to ServerRoot' which may still be difficult to relate to my site's or account's folder?
(Note: The %{DOCUMENT_ROOT} thing actually gives what I need in RewriteRule, can't that be used with AuthUserFile?)
AuthUserFile path-from-here/.htpasswd or
AuthUserFile ../path-from-parent-dir/.htpasswd
Jim
In fact I don't have such large plans that it would be impossible to change it by hand, but I intend to use this kind of approach on multiple sites, and it would be easy to use the same setup everywhere.