How can I tell curl request and browser request

I have a web server and some users are fetching my images using an automated script. I want to redirect them to an error page or give them an invalid image only if it is a CURL request.

my image is in http://example.com/images/AIDd232320233.png

, is there any way i can redirect it using .htaccess to my controller index function where i can check if it is an authentic request?

and my other question is, how can I check the browser headers to distinguish between the most likely genuine ones and the ones that are done with the cURL request?

+3


source to share


1 answer


Unfortunately, the short answer is no.

cURL provides all the options you need to trick any browser. That is, more specifically, browsers identify themselves through certain header information, and cURL provides all the tools to customize the header data in whatever way you choose. Thus, it is not possible to directly distinguish two queries from each other. *

* No additional information. Common methods for determining if Live Human is initiating traffic is by setting cookies during the previous steps (trying to make sure the request is a natural byproduct of the user who is on your website) or using Captcha and cookies (confirm someone may pass the test).

The simplest is to set a cookie, which will really only ensure that bad programmers don't get through, or programmers who don't want to waste time adapting their scraper to your site.



A more elaborate and true approach is Captcha, as it requires interaction from the user to prove they have blood in their veins.

If the image is not a "loadable" image, but more of a larger whole (say, just an image on your site), Captcha can be used to verify a person's identity before granting them access to the site as everything. Or, if it is a download, it will be presented before the download is unlocked.

Unfortunately, Captchas is a pain, both for customization and for the end user. They don't make a lot of sense for general access, they are a little overboard.

For general purpose things, you can really only throttle IPs, download restrictions, etc. And even there you can’t do anything if the mailings are distributed. Their breaks are really ...

+8


source







All Articles