|
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!
Categorized:
CGI Scripts and Web Site Programming
(Article 3727,
Written by Dave Taylor)
Tagged: Previous: Permission to reuse the Wicked Cool scripts Next: Where's this NotePad application? Subscribe!
Anyone know how to do this without using a username? Like just have it ask for a password? thanks I have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
Recommended
Recent Entries
Search
I Need Help!
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and RSS Feeds Building Web Site Traffic Business and Management CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above Facebook Help Google Plus Help HTML and CSS Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Mac OS X Help Pay Per Click (PPC) Advertising Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help WordPress Help |