Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a website (http://mywebsite.com.) for a client, and I would like to create some subdomains like (http://trac.mywebsite.com). I would like to create a password protection for this subdomain, that would be called only for the first time someone entered in http://trac.mywebsite.com: for example, if (http://trac.mywebsite.com/source) is entered, no password is asked.

I know apache is capable of handling users and passwords, but could it be a solution to this feature Im looking for?

Thanks in advance!

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Warner's links are exactly what you need. Though they should be your comprehensive reference they might be a little dry for an introduction to the concept of mod_auth_*. Try googling for "apache htpasswd" or something similar. Here is a decent tutorial to get you started:

http://www.cyberciti.biz/faq/howto-setup-apache-password-protect-directory-with-htaccess-file/

Note: Works the same for subdomains as it does for subdirectories.

share|improve this answer
    
Thanks for the info. Does a password prompt appears every time I hit a subdomain I "protected" with a password? Is it possible to configure this? –  Somebody still uses you MS-DOS Feb 28 '10 at 5:31
    
Generally it will be the first time hitting that particular "realm", or protected area, in a session. After that, the browser will reuse the existing credentials without prompting the user for them each time. –  fission Feb 28 '10 at 6:23

One caution in using the http:// access method and Apache Basic Authentication is that the passwords are sent without encryption. Thus if you using a shared network, this information could be captured.

If you are a little more cautions, you could use https::// where the communication (including the password exchange) would be encrypted between the user and the server.

share|improve this answer
    
Thanks for the info. We are already using https. –  Somebody still uses you MS-DOS Feb 28 '10 at 7:38

For Apache 1.3:

http://httpd.apache.org/docs/1.3/howto/auth.html

For Apache 2.0:

http://httpd.apache.org/docs/2.0/howto/auth.html

share|improve this answer
    
Your second link is broken... Add a "/" after "2.0". Thanks for them though. –  Somebody still uses you MS-DOS Feb 28 '10 at 5:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.