how-to · · 8 min read
how to protect woocommerce download links
A WooCommerce download link is a key, not a file. The settings that decide who can use it and for how long, where files leak anyway, and how to test yours.
By Big Bad Agency
Every few weeks someone finds their paid PDF, preset pack or plugin zip on a forum and asks how WooCommerce let it out. Usually it didn’t, not through the download link. The leak is almost always one of three other things, and the download settings only cover the first one.
This post is the general version: any digital product. If you’re selling an ebook specifically, how to sell an ebook with woocommerce has the numbers we’d use for that job.
what a woocommerce download link actually is
The link a buyer gets is not the file. It’s a link back to your store that carries four things: the product, the order’s key, a hash of the buyer’s email, and the ID of the file. When someone opens it, WooCommerce checks, in order:
- that those four belong together on a real order;
- that the order is in a status that’s allowed to download (more on that below);
- that the file has downloads left and hasn’t expired;
- if the store requires it, that the right customer is logged in.
Only then does it serve the file. So “protecting the link” really means deciding three things: who can use it, how many times, and for how long. Everything else on this page is about the file, which is a separate problem.
1. pick a download method that keeps the file address hidden
WooCommerce → Settings → Products → Downloadable products → File download method.
- Force downloads is the default, and it’s the safe choice. WooCommerce reads the file and streams it to the buyer, so the buyer never sees where it actually lives. WooCommerce’s own help text warns that some servers serve large files unreliably this way.
- X-Accel-Redirect/X-Sendfile is just as private and faster for big files, but your server has to support it (Nginx needs a config rule; Apache needs
mod_xsendfile). Ask your host before you switch. - Redirect only is labelled (Insecure) in the dropdown, and it means it. It sends the buyer’s browser straight to the file’s real address. After that, the address sits in their history and anyone they paste it to can use it, with no order, no limit and no expiry.
Just under it is a checkbox, Allow using redirect mode (insecure) as a last resort. It’s off by default. Leave it off unless you’ve actually seen Force downloads fail on your server. If it’s on, a failed forced download quietly falls back to exposing the real address.
2. decide who can use the link
Same screen → Access restriction → Downloads require login. With it on, a link only works for the customer whose account placed the order. Anyone else gets “This is not your download link.”
There’s a catch, and WooCommerce states it in the setting’s own tooltip: it doesn’t apply to guest purchases. An order placed without an account has no user to check, so for guest orders the link itself is the whole key. Anyone holding it can use it until the limits below run out.
If that matters for what you sell, turn off WooCommerce → Settings → Accounts & Privacy → Enable guest checkout. Then every buyer has an account and the login rule always applies. You’ll lose some checkouts to the extra step, so it’s a real trade-off, not a free win.
3. set how many times and for how long
These live on each product, under Downloadable files: Download limit and Download expiry (in days). Blank means unlimited.
- A limit caps how far one leaked link travels. WooCommerce counts partial downloads by default, but repeat fetches within a short window (30 minutes by default) aren’t counted twice, so a phone resuming a download doesn’t burn the buyer’s allowance.
- An expiry kills old links. It also locks out a real buyer who comes back next year, so if you set one, say so on the product page.
Be more generous than your instinct says. A buyer who opens the email on a second device and hits “download limit reached” becomes a support ticket, and the limit was never what stopped piracy anyway (see the last section).
4. know when access ends
A link stops working when its order is no longer in a downloadable status. That means completed, or processing if you leave Grant access to downloadable products after payment ticked (it’s on by default, and you want it on, or buyers wait for you to complete orders by hand). An order moved to Refunded or Cancelled stops serving its files.
For one bad actor, you don’t need to touch the order status. Open the order, find Downloadable product permissions, and use Revoke access on the file. That same box lets you change Downloads remaining and Access expires for that one customer, which is also how you rescue a genuine buyer who hit the limit.
5. the file is the bigger risk than the link
This is where most leaks actually happen, and none of the settings above touch it.
Files you upload through the product’s “Choose file” button go into wp-content/uploads/woocommerce_uploads/. WooCommerce drops an .htaccess file in there that denies direct access. That works on Apache and LiteSpeed. Nginx ignores .htaccess completely, so on an Nginx host that folder is only protected if someone added a server rule for it. WooCommerce does show an admin notice when the folder is “browsable via the web”, but that check only tests whether the folder lists its contents. It doesn’t test whether a single file opens when you know its address.
That’s why the next setting exists. Filename → Append a unique string to filename for security is on by default and adds a random string to new uploads, so nobody can guess a file’s address. It only affects files uploaded after it’s on. Anything uploaded before keeps its plain name.
Files you pick from the Media Library may not be in that folder at all. A file in the normal uploads/2026/11/ folder is public to anyone who has its address. WooCommerce’s checks protect the WooCommerce link, not that address.
Files hosted somewhere else (a Dropbox, Google Drive or public cloud-storage link pasted into the file URL field) are exactly as protected as that link is on that service. If the share link is public, your limits, expiry and login rule protect nothing, because anyone with the share link skips WooCommerce entirely.
6. test it like someone who wants it for free
Ten minutes, once, after you change anything:
- Place a test order for a downloadable product and copy the download link from the email.
- Open it in a private window. If you require login, it should refuse you until you sign in as that customer.
- Download the file, then check your browser’s download history for the address it came from. It should be your store’s link, not a
/wp-content/uploads/address. - Paste the real file address (from the product’s file URL field) straight into a private window. It should not download. If it does, the file is public, whatever your settings say.
- Open
yoursite.com/wp-content/uploads/woocommerce_uploads/. It should show nothing, an error, or a blank page, never a list of your files.
7. watching for a shared link
Analytics → Downloads lists each download with the product, the order, the user and the IP address it came from. One order downloading from many different IP addresses in a short time is what a link pasted into a group chat looks like. Revoke access on that order, as in section 4, and it stops. Expect a few IPs from a real buyer who switches between home, phone and work, though, so don’t read too much into two or three.
what no setting protects
Once a buyer has downloaded the file, it’s a file on their computer. WooCommerce has no DRM, and nothing on this page stops them emailing it to a friend or uploading it somewhere. Some plugins stamp the buyer’s name into each copy, which discourages sharing. That isn’t core WooCommerce, and it isn’t something we make.
What the settings do protect is the link and the stored file: the parts you control. That’s the realistic goal. Make the easy leak (a public file address, a link that works forever) impossible, and accept that the hard one (a buyer passing on their copy) is a customer problem, not a settings problem.
free files are a different job
Everything above is for files people pay for. A free guide or lead magnet usually isn’t a WooCommerce product at all. It’s a button on a page, and the common leak there is the plain /wp-content/uploads/ address sitting in your page’s HTML.
That’s what we built Secure File Downloads for. It’s free on WordPress.org. You place a download button with a shortcode, and the button points at the plugin’s own download endpoint, so the real uploads address never appears in your page. Be clear on what it doesn’t do. It doesn’t check that anyone paid, so it’s not for paid products. Logged-out visitors can download by default. And it hides the address rather than blocking it, so a file someone already has the direct link to stays reachable. For a paid product, use WooCommerce’s downloads, set up as above.
the short version
- File download method: Force downloads (or X-Accel/X-Sendfile if your host supports it). Never Redirect only, and leave the redirect fallback off.
- Downloads require login, plus guest checkout off, if links must only work for the buyer. Login alone doesn’t cover guest orders.
- Set a download limit and expiry on each product, and be generous with both.
- Refunded and cancelled orders stop serving files. Revoke access on the order handles one person.
- Upload files through the product’s file button, keep “append a unique string” on, and on Nginx get the
woocommerce_uploadsfolder blocked at the server. - Never use a public share link from another service as the file URL.
- Test with a private window and the raw file address, then check Analytics → Downloads for one order coming from many IPs.