Restrict access to folder from purchase URL only
-
Hi,
I’m looking into to restricting URL calls to a folder to the WooCommerce purchase URL only.
The folder contains the files purchased through WooCommerce and I’d like to restrict calls to the folder (https://store.domain.com/view) so that they are only accepted from the purchase URL (ie. https://store.domain.com/?download_file=102&order=wc_order_v7KyqZDgZ&uid=ee8265).The purchase link will forward the request to: https://store.domain.com/view/index.php?code=12345 and the file can then be viewed.
However if someone tries to enter the direct URL (https://store.domain.com/view/index.php?code=12345) I’d like it to fail with a custom error page (to prevent the material to be shared).
I found this tip to restrict calls from one page only, but can’t get it modified to work with a wildcard at the end of the URL:
RewriteEngine On RewriteCond %{HTTP_REFERER} !(www.)?example.com/download-page.php RewriteRule .* - [F]
I’ve tried to modify it to the following but without success:
RewriteEngine On RewriteCond %{HTTP_REFERER} !(^store.domain.com/?download*$ [NC] RewriteRule .* - [F]
So to conclude:
– If call comes from a URL containing “https://store.domain.com/?download……” – ALLOW content in the folder ‘view’ (https://store.domain.com/view/index.php?code=12345)– If call comes directly to https://store.domain.com/view/index.php?code=12345 (or any other URL), DENY content to be displayed.
Any suggestions?
Thanks!
- The topic ‘Restrict access to folder from purchase URL only’ is closed to new replies.