7

I want to create a .htaccess file in my DocumentRoot, so that the directory is password protected.

But the password file, I want to specify by using the relative path of DocumentRoot.

So, if I am checking out the code in another system, it just works as it is. The password file will be part of my source control.

How can I access the parent directory of the DocumentRoot from .htaccess file?

Sabya
  • 11,534
  • 17
  • 67
  • 94
  • possible duplicate of [htaccess AuthUserFile relative path?](http://stackoverflow.com/questions/6111627/htaccess-authuserfile-relative-path) – cweiske May 30 '12 at 16:07

2 Answers2

7

I don’t think that’s possible. The AuthUserFile directive requires the file-path to be either absolute (thus from file system root) or relative from the server root.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
6

The AuthUserFile paths are relative to the server root (/etc/apache2/ on Debian), or absolute.

To take care of different servers, you can use IfDefine directives with different variables on each server - see my blog post about that.

cweiske
  • 30,033
  • 14
  • 133
  • 194