Gossamer Forum
Home : Products : Links 2.0 : Discussions :

htpasswd protect files (NOT directories)

Quote Reply
htpasswd protect files (NOT directories)
Do any of you guys know how to htpasswd protect the admin.cgi file? My server is set up in a way that I can't set up an htaccess for the whole admin folder for security reasons. I don't want to set up any mods to do that either. I KNOW there's a way protect just a certain file but unfortunaly I've failed to find any info on it, everything seems to lead to protecting the whole directory.

If any of you guys know a link or would just explain it here I would be extatic, thank you in a advance :)
Quote Reply
Re: [Kaz] htpasswd protect files (NOT directories) In reply to
Simply put; its not possible. The only way to protect just the CGI files is to write some code into them, which would require you to have a valid cookie on your PC, before it would do anything. I believe there was a mod around a while ago for thisd...but I'm not sure if its still around Frown

Hope that helps.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Kaz] htpasswd protect files (NOT directories) In reply to
I don't know what the other guy is talking about, but it is possible to protect just files. I just did it, in fact. I'm new to this and am tryting to figure out how to protect multiple file in my CGI directory.

I may not know much, but if it works, it works. Here is a sample of the code I'm using in my .htaccess file in CGI directory:

<Files CGIPROGRAM.pl>
AuthUserFile /home/USER/DIR/.htpasswd
AuthName "WHATEVER"
AuthType Basic
require valid-user
</Files>

Hope that works for you! I also hope that people who don't know what theyr'e talking about wouldn't say some is "not possible".

-Philip

www.321green.com

To contact me, click here

Last edited by:

Mr_Green.com: Aug 5, 2003, 7:08 PM
Quote Reply
Re: [Mr_Green.com] htpasswd protect files (NOT directories) In reply to
Update:

I just figured out how to protect multiple files in my cgi-bin directory! It's so simple:

<Files CGIPROGRAM.pl>
AuthUserFile /home/USER/DIR/.htpasswd
AuthName "WHATEVER"
AuthType Basic
require valid-user
</Files>
<Files ANOTHER_CGIPROGRAM.pl>
AuthUserFile /home/USER/DIR/.htpasswd
AuthName "WHATEVER"
AuthType Basic
require valid-user
</Files>

The above is just what I've used, I only added the words in CAPS over my data. Give it a try!

-Philip

www.321green.com

to contact me, click here