Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htaccess files.. how to create and access files

Status
Not open for further replies.

davejam

Technical User
Jan 6, 2004
313
GB
hi all,

been playing with this problem for a while (for my bro's site so in the week work comes first)

i'm setting up a little thing in php for my bro so he can upload images and write little news items... lots of the family live in different countirs so he just wants me to write him a little secure personal network thingy

i've written most of the php and using session variables to secure the pages, its good for what we want.

but i'm also writing a little upload file page so he can put his images up in the same area without having to log into the server etc..

right, i want to have the folder a little secure, so timages in the foilder cannot be viewed by someone typing in the url to the photo... so after looking into folder security and having folder outside (which i can't with this hosting) i was hoping to understand a little of .htaccess, how to create, how to set access.. and how to allow my code into it to display the pics...

have been looking into this on the web but get completely baffled...

just need some pointers to get this one on the way... each member of the family will have their own user and password to sign in but if i can just make sure that theres a valid session i don't mind using a specific user/pass to get into the folder as i'll store this info out of the way anyway

any help would be greatly appreciated

thanks



daveJam

even my shrink says its all your f#@/ing fault
 
can i suggest a different approach? use wordpress as the engine. it's perfect for what you are talking about. not to mention, really well supported and ... free .... you do need a mysql database or a sqlite engine though. for sqlite you'll need to use my plugin at rathercurious.net

in order to stop general access there is a plugin called Angusman's Authenticated Wordpress Plugin that ticks the box with zero effort for you.

but if you really want to go it alone then you need to keep the images outside the webroot or in a directory that has .htaccess set to DENY FROM ALL. you store a pointer to each image in a database and use readfile() or similar to load the images.
 
Code:
htpasswd -c /location/of/file/filename.extension username
it will prompt for a password.

Then create a file named .htaccess in the folder you want to secure with the following...

Code:
AuthUserFile /location/of/file/filename.extension
AuthName EnterPassword
AuthType Basic

require valid-user

That's a simple one.
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top