Apache Configuration


I'm new to Linux. Please help me out to configure apache to require a username and password to access certain documents.

Eg. Say I have "main.html" and other associated files in /usr/temp. I want to restrict the access to the main.html page by providing a username and password. Once a valid username and password are provided the user should be provided access to view this page and the further html files associated with this main.html.

Appreciate if any one of you could provide me detailed step by step procedure, illustrating with an example.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Here is how from the apache week web site.  http://www.apacheweek.com/features/userauth

or when you first set up apache it came up with documentation that you could browse through.  Go to Frequently asked questions #46.  Hope that helps

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tammarAuthor Commented:

I have configured the apache as specified in the documentation but no luck. Its not prompting for the user name and password.

I will explain you what I have done.
1) Created a index1.html file in /home/httpd/html/html1
2) The .htaccess file is in /home/httpd/html/html1
3) The .htaccess file looks like this
          AuthName ByPassword
          AuthType Basic
          AuthUserFile /etc/httpd/users

          require user tammar
4) In "access.conf" included the line
   AllowOverride AuthConfig
to allow the authentication directive thru' .htaccess file.
5) stoped and started httpd.

In the GNOME when i tried to access the index1.html file thru' Netscape Communicator, it's not prompting for the user and the password.

Appreciate if you could help me out.

Note : index1.html is a copy of the file index.html in /usr/doc/HTML.

Have you tried to access it from a Windows based client?  Have you tried restarting your browser?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

tammarAuthor Commented:
Its not right now connected to the net(internet), its only on local network and iam giving the followig command in the "Location" of the browser


I have restarted the browser all the time i tested.

I have not tried to access it from Windows bases client.
It will not prompt you for the username and password if you just access the file, because you are not using the apache server to access the file.  Instead you are just reading the file, which you can do without apache.  Try accessing it this way instead
The does not work I tried it try your host name instead of  In your browser type http://hostname/ do not use www or just use http://ipaddress/ if you do not have a dns setup.
tammarAuthor Commented:
I tried with


Now it does prompt for the username and password but it says

The requested URL http://ipaddress/home/httpd/html/html1/index1.html
not found on this server.
In your access.conf what is the default directory?  is it /var/www?  if so try to put your index1.html in that directory and rename it to index.html (save the old one if there is one) and try to connect http://hostname
also put your .htaccess in that directory.
tammarAuthor Commented:
The default directory (Document Root) is /home/httpd/html.
tammarAuthor Commented:
It works with the above comment.

But why doesn't it take the complete path?

Thanks for your consistent help.

Hostname gets you to the default directory then you are just adding on from there.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.