Log in

View Full Version : .htaccess file



Jamcan
05-01-2010, 11:54 PM
My .htaccess file is shown below;

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/bcfchurch.net/.htpasswd
AuthGroupFile /dev/null
require valid-user


and the .htpasswd in place in the same directory as my public (main) directory, but the htaccess cannot find the htpasswd file.

Is this line correct?
AuthUserFile /home/bcfchurch.net/.htpasswd

djr33
05-02-2010, 12:01 AM
I am not an expert with .htaccess, but I notice two things:
1. That's a very short directory structure compared to what I expect from a server. Is /home/bcfchurch.net really the whole path? If so, that should be fine. But you could check that (in PHP, for example, with echo __FILE__; to find its path).
2. This is using an absolute path, but why not use a relative path? Of course this relates to where the current location of this .htaccess file is.

Jamcan
05-03-2010, 02:54 AM
How do I use the relative path? How do I get any path?

Jamcan
05-03-2010, 02:59 AM
I am not an expert with .htaccess, but I notice two things:
1. That's a very short directory structure compared to what I expect from a server. Is /home/bcfchurch.net really the whole path? If so, that should be fine. But you could check that (in PHP, for example, with echo __FILE__; to find its path).
2. This is using an absolute path, but why not use a relative path? Of course this relates to where the current location of this .htaccess file is.
Not sure how to do this in PHP, for example, with echo __FILE__; to find its path

djr33
05-03-2010, 05:54 AM
You just need to figure out the full directory structure of your host. If you happen to know how to use PHP then that's an option. You could also use ONLY <?php phpinfo(); ?> in a page called "test.php" and find the path that way, I believe.

Regardless, try to look a the documentation for your host to see what the file structure is.

A relative path is just like "file.ext" rather than "/base/directory/file.ext" when you are currently in the same area. So see if you can figure out what that is. In other words, if the password file and the htaccess file are in the same place, then you just need the NAME of the file. If it's in a different location, you will use the relative path like: "../parallelfolder/.htpasswd"