Forum Moderators: phranque

Message Too Old, No Replies

Dynamic password file path for local/live?

Keep the .htpasswd in the same dir as .htaccess regardless of host?

         

JAB Creations

4:08 pm on Jun 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One of my best practices is to ensure that regardless of where my work is hosted that it will just work out-of-the-box. So I recently password protected a directory however I'm having difficulty figuring out how to set the path to be the same directory.

So in the .htaccess file I've tried two paths and got the following error paths in Apache's error log...

AuthUserFile /.htpasswd
C:/.htpasswd

AuthUserFile .htpasswd
C:/MEDIA/INTERNET/XAMPP/apache/

I don't want to set a static path as I want to use the exact same .htaccess file both both the local and live version. If I keep two versions it'll complicate already complicated work and I don't wish to run the risk of irking off my clients.

Also I've tried putting the password file in the directory above the live root (in the FTP root) for security purposes and receive the same errors minus one directory path.
Thoughts please?

- John

JAB Creations

6:33 pm on Jun 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For clarification the Apache documentation states...

If it is not absolute (i.e., if it doesn't begin with a slash), it is treated as relative to the ServerRoot.


[httpd.apache.org...]

Is there a way to go "up" a directory above the drive letter itself?

Or alternatively can I set a variable per {HTTP_HOST} and then set the path depending on the host by chance?

- John

jdMorgan

2:09 am on Jun 16, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like your DocumentRoot is not set correctly.

You will have to use a hard-coded path (relative to DoucmentRoot, at least). Given that problem that your server is not set up like the client's, you have two choices: Either set up your server to match your client's server, or symlink the 'wrong directory' to the 'right directory' on your test server, leaving the client environment 'clean.'

Jim