LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   .htaccess (https://www.linuxquestions.org/questions/linux-newbie-8/htaccess-63637/)

tailine 06-04-2003 10:53 AM

.htaccess
 
I have created a .htaccess file and placed it in the root of /var/www/htdocs/travels dir which is the directory I would like to protect, and I would like to disable dir listing. .htaccess file:

Options -Indexes
AuthUserFile /.htpasswd
AuthName "travel"
AuthType Basic
AuthUserFile /var/www/htdocs/travels
Require valid-user

After this I have also created a .htpasswd file in the root of my system with the user name of travels using the command = htpasswd -c /.htpasswd travels

It does not seem to work, do I need to update anything in my httpd.config file in order for apache to pick up .htaccess? or how can I get this going?
p.s. i am using slackware 9
thanks

david_ross 06-04-2003 12:29 PM

The command you have used:
command = htpasswd -c /.htpasswd travelsWould be put in the / dir not in /var/www/htdocs/travels

trickykid 06-04-2003 01:39 PM

Quote:

Originally posted by david_ross
The command you have used:
command = htpasswd -c /.htpasswd travelsWould be put in the / dir not in /var/www/htdocs/travels

So to clarify, what David is saying is.. type the full path to .htaccess.. and you don't need two AuthUserFile's

Example:

Options -Indexes
AuthUserFile /var/www/htdocs/travels/.htaccess
AuthName "travel"
AuthType Basic
Require valid-user

tailine 06-05-2003 04:14 AM

After reading some documentation on .htaccess it was stated that the .htpasswd file should be created in a directory outside the /var/www/htdocs and the .htaccess file should point to the location of the .htpasswd due to security reasons, that is why I have created the .htpasswd on the / of the system.
Is this not the case should both .htaccess and .htpasswd files be in the dir that I am protecting?

david_ross 06-05-2003 04:59 AM

To clarify:
file /var/www/htdocs/travels/.htaccess
Code:

Options -Indexes
AuthUserFile /.htpasswd
AuthName "travel"
AuthType Basic
AuthUserFile /var/www/auth/.htpasswd
Require valid-user

file /var/www/auth/.htpasswd
Code:

username:crypted-passwd
I usually create a directory called users or auth and put it outside the DocumentRoot. You will need this directory and both .ht files readable by the web server.

tailine 06-05-2003 05:03 AM

Thanks ill give that a go

trickykid 06-05-2003 08:51 AM

I'm still not understanding why your specifying the .htaccess file with two locations for AuthUserFile ?? You should only really need one pointing to the actual location of the .htpasswd file.

tailine 06-05-2003 10:07 AM

Sorry that was my mistake, i think all the is left is to restart my apache server but when running the command kill -HUP (pid number of httpd) i am not completely sure this is restarting thou as i am getting no change and the pid number is always the same when i check. After reading through the documentation of restarting the server it states the following command
kill -HUP /usr/local/apache/logs/httpd.pid
there is no such location on my machine or no such file.
How can i restart it and know that it has restarted?

trickykid 06-05-2003 10:34 AM

Quote:

Originally posted by tailine
How can i restart it and know that it has restarted?
apachectl restart

But if you already have the .htaccess directive in the httpd.conf file, there is no need to restart it. Only if you make direct changes to the file itself. If you already had it setup, then the .htaccess and .htpasswd is already in affect when you set those up.

david_ross 06-05-2003 10:39 AM

Sorry I meant to take the first one out - I forgot when I copied and pasted.

trickykid 06-05-2003 10:44 AM

Quote:

Originally posted by david_ross
Sorry I meant to take the first one out - I forgot when I copied and pasted.
There are no excuses for your actions.. you must be assimilated... or something like that.. :D

I'm sorry.. in a good mood.. its raining.. I love the rain.. :)

tailine 06-05-2003 11:54 AM

This i still not working, i am trying to check the directive in the httpd.conf but i am not sure what i am looking for.
What command do i need to set?

tailine 06-05-2003 12:03 PM

The following commands are set up in my httpd.conf file

AccessFileName .htaccess

trickykid 06-05-2003 12:08 PM

Make sure you have these in your httpd.conf file:

Code:

# This to look for filename to access control information

AccessFileName .htaccess

# This to prevent the .htpassword and .htaccess files from being able to be viewed.

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>


# And also something like this placed in your <Directory> directive tags, etc:

    AllowOverride AuthConfig Limit


tailine 06-05-2003 12:09 PM

Here is the total directive set in httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory "/var/www/htdocs">

AllowOverride None

Order allow,deny
Allow from all
</Directory>

<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

IncludesNoExec

<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>

AccessFileName .htaccess

<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</Files>


All times are GMT -5. The time now is 11:26 AM.