how to hide Access to media files in a directory, if we have the full URL for a file. How to, I make an online store, so to download one of the files in my store, I have to log in first, then it can be downloaded, for example https://mystore.com/product/widia/ they must log in first, but if we access it from the url of the file, for example https://mystore.com/wp-content/uploads/2019/01/widia.ttf then the file is downloaded immediately, Please help


Just in general.....

Put an index.html file in the directory. Leave this index file completely blank (no markup or text whatsoever - although you can style it or add content if you desire).

When a user targets the URL the index.html file is called an they merely see a blank page (or the content of the index.html file).

This does not prevent direct access to items within the directory if the full path and file name is known. However, it does prevent "browsing" of the directory itself.

I place a blank index file in every directory which is not meant to be viewed by anyone over the web - even if the access is limited via server configurations. The blank file hurts nothing if it is not necessary, but will prevent browsing if it is needed.


If this is a "store" and you are selling items in a directory and want to prevent access to those files, even if the file path is known, you need much more robust protection via some server-side scripting (php/asp) and authentication to control the access to downloads. It's not an easy answer especially if you aren't familiar with server-side scripting.

In general you'd probably set an authorization cookie after purchase. When the user accesses the download directory, the cookie is checked to see if it is valid. If the cookie is not valid, has timed out, or is simply not present, the user is rejected from the directory and unable to download.

StackOverflow.com is site in the stack network more directed at web site configuration, creation, and assistance with those matters. this stack isn't really geared towards assisting with server-side scripting.

  • Thank you so much for your help, – marwah Jul 8 '19 at 2:52
  • right, this is for the shop, where can I find help for my shop, so that we can avoid being accessed in the url of one of the files directly, because if that happens it is very detrimental to the shop owner, people who know the url of one of these files can be downloaded without having to buy,thanks – marwah Jul 8 '19 at 2:58
  • You really should hire a developer. – Scott Jul 8 '19 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.