How To Bypass Cloudflare Hotlink Protection?

A remote server used cloudflare service on their web. So, Cloudflare take action to prevent any hotlinking to this web. As result, images from this web not shown properly.

What is Hotlinking?

Hotlinking is a term used on the Internet that means displaying an image on a website by linking to another website to obtain the source data of the picture each time it is needed, rather than saving a copy of it on the website on which the image will be shown. (wikipedia)

 

As Cloudflare says:

When enabled, the “Hotlink Protection” option ensures that other sites cannot suck up your bandwidth by building pages that use images hosted on your site. Anytime a request for an image on your site hits Cloudflare, we check to ensure that it’s not another site requesting them. People will still be able to download and view images from your page, but other sites won’t be able to steal them for use on their own pages.

 

Can we bypass it?

Offcourse we can! easy way to bypass hotlinking using base64 encode image. The image that will displayed from their web (remote) to this web, should converted to base64.

Finally, here is the code 🙂

function lancarjaya($img_file)
{

$imgData = base64_encode(file_get_contents($img_file));
$src = 'data: '.mime_content_type($img_file).';base64,'.$imgData;

return $src;
}
Share to

Do You Know!