Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-26-2004, 11:52 AM
|
#1
|
Member
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212
Rep:
|
how do I poassword protect a directory on a website, Apache
I know how to password protect a directory on a whole website. But what do I do if I have a site line www.site.com/private .
I want to put password protection just for the "private" sub-directory and not the rest of the site. Thanks in advanced
|
|
|
04-26-2004, 12:26 PM
|
#2
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
|
|
|
04-26-2004, 05:38 PM
|
#3
|
Member
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212
Original Poster
Rep:
|
riiiiight....that still doesn't tell me how to do it for just one directory in the website. I have already looked at that document anyway. It doesn't really tell me how to do it for one directory. Can anyone give an example, I will understand it better then. In my virtual hosts section, what would I do to add basic authenication to just one directory in the website?
|
|
|
04-26-2004, 05:58 PM
|
#4
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
Well, you place the .htaccess file in the directory you want to protect.. just take note it will ask for a username and password if that one directory has any subdirectories.. but that is what your looking for, I promise
|
|
|
04-26-2004, 10:37 PM
|
#5
|
Member
Registered: Mar 2004
Location: North Bay, Ontario - CANADA
Distribution: Debian
Posts: 77
Rep:
|
1) make a .htaccess file in the dir you want to protect with the following:
Code:
AuthUserFile /path/to/dir/.htpasswd
AuthGroupFile /dev/null
AuthName "This is my server"
AuthType Basic
require user {username]
2) at the command prompt in the above dir -
htpasswd [-c] .htpasswd {username} (the -c flag creates the .htaccess file)
3) add this to your httpd.conf file and restart your server
<Directory /path/to/dir/>
AllowOverride All
</Directory>
this will give you the following output - http://kroell.homeip.net/private
Last edited by tuxguy; 04-26-2004 at 10:46 PM.
|
|
|
04-27-2004, 07:51 AM
|
#6
|
Member
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212
Original Poster
Rep:
|
Thanks guys. When I try thought I get error 1049 AuthUserFile not allowed here.
Also I have a wierd set up. I have a directory with a lot of files. So I want to password protect that directy. However the directory isn't on that server. here is the setup.
I have a web server running LAMP I'll call it server1.
I have another server with a lot of files, running NFS, server2.
I exported a directory called "files" in etc/files for example. in etc/exports.
I mounted server2:/etc/files in /mnt/files.
Then in the web directory I created a link called private to /mnt/files.
I did this ln-s /mnt/files /user/site/private
I did this because server2 has a ver large hard drive and I have a lot of files. It's running samba to, so I just drop files into it from my widows box and I am set.
It works great and I have no problems acces the stuff. I just want to password protect that directory. I also noticed I can't add the .htaccess file to the .private directory because it doesn't actually reside on that machine. so I added it to the root of the site ultimately and got this error.
I have apache 2 (Redhat distrubution)
|
|
|
05-04-2004, 11:58 AM
|
#7
|
Member
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212
Original Poster
Rep:
|
I figured this out too. I tried putting the Authuserfile and stuff in the virtual directory containers. I guess you can't do that.
You have to put the in a directory container.
|
|
|
06-01-2004, 06:34 AM
|
#8
|
LQ Newbie
Registered: Apr 2004
Location: Provo, Utah, USA
Distribution: SuSE 9.0 Professional
Posts: 19
Rep:
|
This may be a stupid mistake but, i did exactly as tuxguy told. this is from my httpd.conf file
<Directory /srv/www/htdocs/phps/secret>
AllowOverride all
</Directory>
and this is inside my /secret folder.
ErrorDocument 401 rejection.html
AuthUserFile /home/wasiq/.htpass
AuthGroupFile /dev/null
AuthName "Book-O-Rama"
AuthType Basic
Require user [username]
and this is from that .htpass file
user1: nnWZGCar5gVY2
user2: 4fQGZ/I/eE9kQ
user3: oAejr3UGjRLXw
now, i restarted my apache2 from runlevel editor of YaST but, still i can see the index.html page inside /secret folder...
ANY CLUE What did I do wrong? or What DIDN'T I do yet to make it work???????
|
|
|
06-17-2004, 12:12 PM
|
#9
|
Member
Registered: Mar 2003
Location: Washington DC, USA
Distribution: Redhat
Posts: 212
Original Poster
Rep:
|
ErrorDocument 401 rejection.html
AuthUserFile /home/wasiq/.htpass
AuthGroupFile /dev/null
AuthName "Book-O-Rama"
AuthType Basic
Require user [username]
the above needs to be in the directory directive.
|
|
|
All times are GMT -5. The time now is 07:19 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|