Members CMS
PHP 8.1+ & MySQL Buy license · $349.95
Hosting & security

Protecting member media from direct links

If a file sits in a public folder, anyone with the link can open it. How to keep originals outside the web root and serve media through expiring links.

Updated 5 minute read The Members CMS team

On a membership site, your photos, videos and stories are the product. Members pay for access to them. But if those files sit in a public folder on your web server, anyone who learns or guesses the address can open them, whether or not they are a member, and they can pass that address on to anyone else.

This guide explains how direct links leak content, why hiding files behind odd names isn't enough, and how to store and deliver media so that it only reaches the people and websites meant to see it.

A web server will usually hand over any file inside its public folder to anyone who asks for it by address. Your members area may sit behind a login, but the files themselves don't know that. If a photo lives at a plain, predictable address, it can be opened directly, with no login at all.

Addresses leak in many ordinary ways:

  • Folder or file names follow a pattern, so the next set is easy to guess.
  • A member copies a link to a file and posts it on a forum or sends it to a friend.
  • Thumbnails or previews of content you have not published yet are stored in public folders.
  • Search engines find and index files that were never meant to be listed.
  • Old links keep working long after a set has been archived or removed.

Why hard-to-guess names are not enough

A common first fix is to give files long random names. That does make guessing harder, but it doesn't control access. Once someone has the link, they can share it and anyone else can open it, for as long as the file stays where it is. There is no way to take it back without renaming the file.

Random names are a reasonable extra layer, but the real protection comes from three things: keeping files out of public reach, checking permission every time a file is requested, and making any link that does get handed out stop working after a short time.

Store originals outside the web root

The web root is the folder your web server makes public. Anything inside it can potentially be fetched directly. Anything outside it cannot be reached by address at all.

The safer approach is:

  1. Store original files, thumbnails and previews in a folder outside the web root.
  2. When a file is requested, the application checks whether it may be shown.
  3. If it may, the application delivers the file. If not, it refuses.

This is often called access-checked delivery. The address the visitor sees points at the application, not at the file itself, so there is no folder to browse and no file path to guess.

Access checks work well when the files and the members area are on the same server. When they are on different servers, a common answer is the signed, expiring link. The members area asks for a link to a file, and the link it gets back carries a signature and a time limit. The server holding the files checks the signature and the time before sending anything.

The result is that a copied link is only useful for a short while. Post it on a forum and by the time anyone else clicks it, it has expired. Change one character and the signature no longer matches.

ApproachStops guessing?Stops shared links?Checks each request?
Public folder, plain namesNoNoNo
Public folder, random namesMostlyNoNo
Outside web root, access-checked deliveryYesYes, when access is checkedYes
Signed links that expireYesYes, after a short timeYes

If your member sites and your media live on different machines, our guide to serving member media from another server compares the two set-ups in more detail.

What else needs protecting

Thumbnails and previews too

It is easy to protect the full-size originals and forget the small versions. But a thumbnail or preview can give away exactly what a set contains, including one you have not published yet. Treat every generated file, including video posters, with the same rules as the original.

Access per website

If you run several sites from one library, each site should only be able to fetch the content its own rules allow. A set meant for one site should not become reachable through another just because both talk to the same library. Separate credentials for each website make this much easier to enforce.

Archived and removed content

Archived or deleted sets should stop being reachable straight away. With access-checked delivery this happens automatically, because every request is checked against the item's current status rather than relying on a file being in a particular folder.

Other good habits

  • Turn off directory listing so visitors can't browse folder contents.
  • Always use HTTPS, so media and logins aren't sent in plain text.
  • Make sure the members area really does require a login - see members area logins: folders, sessions and cookies.
  • Check that uploaded files are what they claim to be and that file names are made safe.
  • Review your logs now and then for unusual access patterns.

How Members CMS handles this

Members CMS serves media only through access-checked URLs, and the installer suggests a storage folder outside the web root. Only Published content goes to websites, content not yet released to a site by its drip schedule is not shown in that site's members area, tour, search or direct links, and each website has its own credentials, so a site can only fetch the content its own category rules allow. Requests between each site and the CMS are signed with HMAC-SHA256 and only accepted within a 5-minute window.

Nothing is copied to your websites. For each website you choose a delivery mode: "different server", where files load from Members CMS through signed links that expire, or "this server", where the connector streams straight from the storage folder with signed tokens. Uploads are checked for their real file type, so a disguised script is rejected, and file names are made safe.

Frequently asked questions

Why not just use hard-to-guess file names?

Long names make guessing harder, but anyone who gets the link can still share it. Storing files outside the web root and checking access on each request is far safer.

Should thumbnails be protected too?

For content that is not published yet, yes. A thumbnail or preview can give away content you have not published.

What about content that should only show on one of my sites?

Access should be checked per website. Each site should only be able to fetch the content its own rules allow, never another site's.

Get three guides like this every month, plus software update notices.Subscribe →