AuthUserFile path relative to virtual host root

.htaccessapache-2.2cross platformmod-auth

Given this folder / file structure:

private/.htpasswd
public/.htaccess

… where public is the root folder of a virtual host in Apache, and private is its sibling folder:

How do I define a relative path for AuthUserFile in the .htaccess file, such that it is able to access /private/.htpasswd

I've tried:

AuthType Basic 
AuthUserFile ../private/.htpasswd
require valid-user

But that doesn't work, because it tries to find the file relative to the ServerRoot, in stead of relative the virtual host root.

I won't have access to the config file on the production server (shared host) and I don't want to define an absolute path, because my testing and production file system structures don't match.

Is it still possible to achieve what I want, given these conditions?

Best Answer

You may use symlink on testing system, for example /srv/www/vhost/private/.htpasswd -> /var/www/vhost/private/.htpasswd. The first path need to be same as on production server. Then you will be able to use the same paths on both servers. Options FollowSymLinks may be required for this. I don't see any way to include config files not relatively to ServerRoot.