
How to use Apache htaccess to password protect a directory
In a rather lengthy email message, a reader writes to me that:
I am following your book Creating Cool Web Sites with HTML, XHTML and CSS and am trying to protect a subdirectory on my website. The following is the .htaccess codeAuthUserFile /www.bvg.us/uswholesale/uspasswords/passwords.txt AuthGroupFile /dev/null AuthName "Please enter your login name and password" AuthType Basic <Limit GET> require user weiyang require user annawei </Limit>The "passwords.txt" readsuser weiyang:wy user annawei:awBy doing so, I can get the "log in" box but can not login with the info that I set. Could you help me on this? The easiest way to generate the encrypted passwords is to use ssh (or telnet if you must) to connect to the server, then type the command htpasswd passwords.txt acct for each of the accounts you want to create. The program prompts you for the desired password, encrypts it, and then adds the appropriate line to the password file automatically. If you don't have the htpasswd command available, you can download a copy of the program from my Wicked Cool Shell Scripts book Web site, portably written in Perl. Once you've done that, your password file should look more like this: admin:VKJ994JdmWHxA tintin:gjpumwPY/bRv2 banana:9NPJc88Ky9AWQ barney:rAuOt0D7IChF. joe:4o19P5g5hlPZUHope that gets you up and running!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
CGI Scripts and Web Site Programming
(Article 3727)
Tagged: Previous: Permission to reuse the Wicked Cool scripts Next: Where's this NotePad application? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. Anyone know how to do this without using a username? Like just have it ask for a password? thanks I have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|