Web Hosting Talk







View Full Version : Enabling .htaccess and .htpasswd


Lord MJ
12-19-2001, 01:41 AM
To enable these files do I have to edit httpd.conf or recompile apache, right now I'm trying to create a directory for phpMyAdmin and other protected files, and I want to set up a .htaccess for user authentication.

bobcares
12-19-2001, 06:17 AM
Hi!
Mostly all hosting companies have htaccess enabled by default in which case you have to do nothing to the server config files otherwise you have to add the following line

AllowOverride All

and then restart your apache

Have a great day :)

regards
amar

Lord MJ
12-19-2001, 02:15 PM
Ok I edited httpd.conf and restarted apache, however my .htaccess isn't doing anything.

bobcares
12-19-2001, 02:18 PM
Can you give me some details about your server.
Also I would like to know what are the steps you have taken. and what the contents of the .htpassword are like.

Have a great day :)

regards
amar

bobcares
12-19-2001, 02:29 PM
Hi Again,
Here's what you must do.

Using vi , create a file called .htaccess with the following contents. -

AuthUserFile /home/dirname/www/.htpasswd
AuthName "The Protected Page"
AuthType Basic

<Limit GET POST>
require valid-user
</Limit>


Change the AuthUserFile so that the UNIX PATH matches that of your system. This is where the password file that we will create in a moment will reside.


To create the password file, issue the following command:
htpasswd -c .htpasswd user_name (where user_name is a name)

The system will ask you to enter the password for this user. It will then ask you a second time to confirm your typing.

Also I assume that the AllowOveride All is given in the httpd.conf.

Have a great day :)

regards
amar

Lord MJ
12-19-2001, 03:13 PM
ok I did everything that you said with htpasswd already. And I have created an alias to my directory, and in that alias I set AllowOveride All, should I do this in an alias, or is there a way to do it for my entire Apache server?

bobcares
12-19-2001, 03:19 PM
If the "AllowOveride All" shoud be set either globally or for a particular virtual host. Just setting for a directory would not work...

Try setting it globally and seeing the results..

Have a great day :)

regards
amar

Lord MJ
12-19-2001, 03:56 PM
Ok I got it to work.


Not only was the alias pointing to the wrong folder, but there was a syntax error in my .htaccess file. Everything's working fine now, but how secure is .htaccess authentication?

bobcares
12-19-2001, 04:16 PM
Security is not the best with htaccess. But it is quite reliable and quite widely used.... :)

Have a great day :)

regards
amar