php forum
php mysql forum
php mysql smarty
 
Topic Options
#248229 - 05/27/03 11:24 PM Password Protect one file
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
I usually use an .htaccess file like this to password protect directories.<br /><br />[]<br />AuthUserFile /home/blah/blah/lunch/blah/.htpasswd<br />AuthGroupFile /dev/null<br />AuthName "phpProtection"<br />AuthType Basic <br /><br /><Limit GET POST><br />require valid-user<br /></Limit>[/]<br /><br />Can you use .htaccess to password protect only a single file? Or does it always have to be a whole directory?
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#248230 - 05/28/03 04:04 AM Re: Password Protect one file [Re: Daine]
Ian_W Offline

Veteran

Registered: 02/22/02
Posts: 2575
Loc: England
AFAIK - it a directory level thing only - I suppose you could put that file in a unique directory and then in htaccess redirect anyone viewing that file, to the one in the unique directory - that way the one file would be passworded, simply because the entire directory is.<br /><br />Havn't tried it, but that ought to work.<br /><br />
_________________________
Fans Focus - Focusing on Fans of Sport

(Okay - mainly football (the British variety wink at the moment - but expanding all the time....)

Top
#248231 - 05/28/03 08:17 AM Re: Password Protect one file [Re: Gorlum]
msula Offline
Addict

Registered: 02/18/02
Posts: 1969
Loc: Lansing, Michigan
Ian is correct, I don't think you can password protect an individual file, at least not with .htaccess I don't think. The only real restrictions you can put on files by default is by CHMOD, but when restricting a file that way, you will either allow or dissalow permission, there is no password prompt. <br /><br />If someone knows of a way to do this, it would be good to know. But I think CHMOD will restrict files too much, and .htaccess will only work on a directory level.

Top
#248232 - 05/28/03 10:00 PM Re: Password Protect one file [Re: palmen]
navaho Offline
Veteran

Registered: 10/05/00
Posts: 2518
Loc: navahoville! :D
Sure, why not. <br /><br />Stick this in your httpd.conf in your virtual host container. It will probably work with an .htaccess too.<br /><br /><Files /path/to/myfile.php><br />AuthUserFile /home/blah/blah/lunch/blah/.htpasswd<br />AuthGroupFile /dev/null<br />AuthName "phpProtection"<br />AuthType Basic<br /><br /><Limit GET POST><br />require valid-user<br /></Limit><br /></Files><br /><br />What I can't remember is ... is it <Files or <File<br /><br /> <img src="/forum/images/graemlins/doah.gif" alt="" />
_________________________
Picture perfect penmanship here.

Top
#248233 - 05/28/03 10:30 PM Re: Password Protect one file [Re: zerind]
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
Navaho - once again - you are my hero. <img src="/forum/images/graemlins/grin.gif" alt="" /><br /><br />It is "files" and did work in .htaccess<br /><br />The only difference was that since I was putting the .htaccess file in the directory that the file was in - I didn't need the whole path in the first line - just the filename.<br /><br />Then it worked like a charm. <img src="/forum/images/graemlins/grin.gif" alt="" /><br /><br />Thank you!!!!!! <img src="/forum/images/graemlins/grin.gif" alt="" />
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#248234 - 05/29/03 01:27 PM Re: Password Protect one file [Re: Daine]
navaho Offline
Veteran

Registered: 10/05/00
Posts: 2518
Loc: navahoville! :D
<img src="/forum/images/graemlins/wink.gif" alt="" />
_________________________
Picture perfect penmanship here.

Top
#248235 - 05/29/03 01:32 PM Re: Password Protect one file [Re: zerind]
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
<img src="/forum/images/graemlins/bow.gif" alt="" /><br /><br /><img src="/forum/images/graemlins/bow.gif" alt="" /><br />
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#248236 - 05/29/03 01:46 PM Re: Password Protect one file [Re: Daine]
Ian_W Offline

Veteran

Registered: 02/22/02
Posts: 2575
Loc: England
Might want to move this to Design Matters - as it is a very useful tip <img src="/forum/images/graemlins/smile.gif" alt="" /> Thanks Navaho.<br /><br />Of course Jeremy & I knew this - but want to test Navaho's knowledge...... I wish!!
_________________________
Fans Focus - Focusing on Fans of Sport

(Okay - mainly football (the British variety wink at the moment - but expanding all the time....)

Top
#248237 - 05/29/03 06:05 PM Re: Password Protect one file [Re: Gorlum]
msula Offline
Addict

Registered: 02/18/02
Posts: 1969
Loc: Lansing, Michigan
haha.. yeah, really I was just testing rick's skills <img src="/forum/images/graemlins/laugh.gif" alt="" /> But no.. I had no idea you could do that, so I have added it to my list of useful information <img src="/forum/images/graemlins/smile.gif" alt="" />

Top
#248238 - 11/02/03 02:54 PM Re: Password Protect one file [Re: palmen]
marylin77 Offline
Lurker

Registered: 11/02/03
Posts: 1
very interesting...but I have a "little" question. <br />What do I have to write in .htaccess file? <br />Regards from Spain. <br />Details: <br />I use windows millenium and I have to protect ONLY one file called admin.php located in folder SITIO56. <br />In SITIO56 there are more files, but I only want to protect admin.php.


Edited by marylin77 (11/02/03 02:55 PM)

Top



Moderator:  Charles 
Latest Posts
[7.2.1] - Naked shoutbox
by bellaonline
05/05/12 05:00 PM
[7.x] Stop Forum Spam Integration v0.4
by bellaonline
05/05/12 03:53 PM
Shout Box

(Views)Popular Topics
Known public proxy servers 1689885
Integrated Index Page (IIP) 5.3.1 555705
Finished-[6.5.2] Games Arcade Deluxe v1.9 501236
Integrated Index Page (IIP) 5.1.1 415112
TLD Bv2.1 Released - Threads Links Directory 396822
[6.0x] Who's Online 4.0.0 [Finished] 389412
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 330423
Q & A 298663
Slash UBB 266936
[6.3.x] [beta] Hit Hack 2.0 227970
Forum Stats
13621 Members
59 Forums
37191 Topics
295716 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks