Securing folder using Apache and PHP

Posted on 2005-04-15
Medium Priority
Last Modified: 2010-03-04
I have login system writen on PHP and uses MySQL database.  On the server I have folder which contains html files and pictures, like:




Every user have a number that is stored in his MySQL, and I want to prohibit folder from being browsed by every body exept that user only can see files which are starts from his number.  For example user "yo" have a number "3" stored in his database. I want hi m to be able only see files 3.html & 3.jpg and denied access from his to view any other files!

Is is possible to do something like this using apache and php security. By the way I was using session auth.  If needed .html files can be changed to .php and some security can be added to protect them from being viwed, but how can I protect the pictures???

Thank you...
Question by:g00r00
  • 2
  • 2

Author Comment

ID: 13800150
Anybody? Any clues?
LVL 14

Expert Comment

ID: 13800361
no apparent idea...the best i can think of is either complicated scripting, or seperated folders...i'm not really sure...i've never tried something like this before...

LVL 14

Expert Comment

ID: 13813335
May I suggest that instead of doing this by filename, you allocate each user their own directory and restrict access like that?

Note that you will need to set up per directory .htaccess restrictions for this at the least, so you will need to add users both to the database and to .htaccess.

Author Comment

ID: 13825273
Does any one know any free php scripts that work with MRPG graphs? This is why I am trying to do.!
LVL 14

Accepted Solution

cracky earned 1000 total points
ID: 13825378

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question