Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:14:31+00:00 2026-06-08T07:14:31+00:00

need some help… I need to protect all the FOLDERS in a DIRECTORY from

  • 0

need some help…

I need to protect all the FOLDERS in a DIRECTORY from direct URL access. Can I do this with .htaccess and if yes, how? Or is their a safer method?

Here’s my situation, I allow a user to UPLOAD a a pdf file.

The file is sent to /uploads/{userid}/{filename}

This all works dandy, but the issue is that the PDF can be accessed directly if someone knows the {userid} and {filename}

I want to secure the uploads directory and all sub directories from direct URL access.

At the same time however my database (MySQL) needs to be able to browse the uploads directory and sub directories to confirm that a PDF file was uploaded and let the admin download the file from the admin control panel.

Now I’m not asking you to write my code. I’m just letting you know my specs because I assume someone might suggest htpasswd but I don’t think I can use that solution as per my requirements.

If you have a simple solution or if you can point me on the right track to a tutorial please do so.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:14:35+00:00Added an answer on June 8, 2026 at 7:14 am

    As Fabio points out – it’s better to keep such files out of web root. But you still CAN use .htaccess to protect the files. They’ll be guaranteed protected unless you accidentally delete the .htaccess or the sysadmin changes the main configuration (which sometimes happens).

    Just put a an .htaccess into the directory you want to protect, and put a single line in that .htaccess:

    deny from all
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help in creating function which can create folders recursively with giving path:
Need some help with a #jQuery issue. Can someone look at this and tell
Need some help to solve this. I have a gridview and inside the gridview
Need some help with this problem in implementing with XSLT, I had already implemented
Need some help gathering thoughts on this issue. Our team is moving ahead with
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help with this error. Fresh wordpress 2.9 install... Fatal error: Cannot instantiate
Need some help on understanding how to do this; I'm going to be running
Need some help please with this error : TypeError : 'unicode' object does not
need some help figuring this out. My function: function cleanDatabase() { $allowedTime = $this->time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.