Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Password protection using Apache

Posted on 1999-06-24
7
Medium Priority
?
199 Views
Last Modified: 2013-12-25
Hi everybody!

I know there's a way to limit access to certain html files using Apache/Linux, but I don't know how to do this.
I have a directory, and all htm files in there should only be accessable after entering a name and a password.
I could do this with CGI, but I would like it a lot better, if Apache could handle it.
My version of Apache is 1.3

Regards, Oli
0
Comment
Question by:Oli2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:nettrom
ID: 1863472
Apache uses .htaccess files for authentication as far as I know.  the Apache FAQ on http://www.apache.org/docs/misc/FAQ.html had some information.  also a search for "htaccess" on the Apache web sites returned a few hits.

documentation on .htaccess can be found on (as reported by Google):

Mosaic User Authentication Tutorial http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html

Dynamic configuration, .nsconfig, and .htaccess http://help.netscape.com/kb/server/960513-104.html

Apache Core Features http://www.apache.org/docs/mod/core.html

this should give a few leads. :)
0
 
LVL 1

Author Comment

by:Oli2
ID: 1863473
Hi, nettrom!

Thanks for your answer. I believe, a .htaccess file does only override the <directory> settings. What I need is the Apache to bring up a "enter username and password" dialog whenever somebody enters the directory I want to protect.

Regards, Oli
0
 
LVL 7

Expert Comment

by:nettrom
ID: 1863474
one of the things you can use .htaccess to is to protect a directory and all sub-directories below it. :)

I found a URL through a search on Deja News:

http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html

seems like it's a tutorial.  I also found this example code (.htaccess) in one of the posts:

.htaccess:

AuthUserFile /home/i98/ksu/havard/.htpasswd
AuthGroupFile /home/i98/ksu/havard/.htgroup
AuthName Klassefest
AuthType Basic

<Limit PUT HOST HEAD>
require user per
</Limit>

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

you'll also need to use the program 'htpasswd' because the password has to be encoded.

if you want to password protect a directory and use the usernames & passwords installed on your system I'm not knowledged on that though. :/
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 1

Author Comment

by:Oli2
ID: 1863475
Hi, nettrom!

Thanks for your answer. I believe, a .htaccess file does only override the <directory> settings. What I need is the Apache to bring up a "enter username and password" dialog whenever somebody enters the directory I want to protect.

Regards, Oli
0
 
LVL 1

Author Comment

by:Oli2
ID: 1863476
Hi nettrom!

Sorry for accidently posting the same comment again.
Thank you for your answers. You were right. It works fine this way.
Post it as an answer and you'll get the points :-)

regards, Oli
0
 
LVL 7

Accepted Solution

by:
nettrom earned 150 total points
ID: 1863477
great, thanks.  I'll try to summarize and give the right URLs in one sweep. :)

first of all, the Apache FAQ.  always a good place to start looking is the FAQ, even thoug as far as I could see the information you were looking for wasn't actually there.

http://www.apache.org/docs/misc/FAQ.html

Apache's authentication builds on the NCSA httpd authentication.  a documentation/tutorial for the NCSA authentication can be found on http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html

Netscape also has some information out regarding .htaccess, or their equivalent .nsaccess which can be found on http://help.netscape.com/kb/server/960513-104.html

an example .htaccess file can look like what I'll show in just a second, but before I do that I'll remind about the program 'htpasswd' which needs to be used to encode the password for transmission across HTTP.  without it authentication will fail. :)

sample .htacces:

AuthUserFile /home/i98/ksu/havard/.htpasswd
AuthGroupFile /home/i98/ksu/havard/.htgroup
AuthName Klassefest
AuthType Basic

<Limit PUT HOST HEAD>
require user per
</Limit>

<Limit GET>
require valid-user
</Limit>
0
 
LVL 1

Author Comment

by:Oli2
ID: 1863478
Also, don't forget to change the "AllowOverride" in /etc/httpd/httpd.conf into "All" instead of "None". Otherwise Apache will ignore .htaccess files !!

Regards, Oli
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question