Answer the question
In order to leave comments, you need to log in
How to restrict downloading a file from a direct link?
The point is this: the site is a small self-written online store in PHP.
After payment, the user is directed to a page where a special script gives him links to download the files he paid for.
It is necessary to make sure that the direct links issued by the script are not accessible from the outside, outside the script. How can I do that? I hope I explained clearly
Answer the question
In order to leave comments, you need to log in
Based on the X-Accel-Redirect header and the internal directive in nginx, you can implement any logic to restrict access. And unlike sending the file directly by a php script, this option is much more efficient, because. The php script will only do the access check, and nginx will already take care of the return.
Usage example: www.opennet.ru/base/net/nginx_x_accel_redirect.txt.html
It is possible to issue a file through a PHP script that, before sending the file, checks whether the user is logged in or not and whether he paid for the file or not.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question