Securing folder using Apache and PHP

Posted on 2005-04-15
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

    Author Comment

    Anybody? Any clues?
    LVL 14

    Expert Comment

    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

    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

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    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 ( to http…
    If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now