Support » Plugin: Image optimization & Lazy Load by Optimole » Prevent hotlinking

  • Resolved 温唯

    (@unbosomjam)


    Hi
    I have Cloudflare to prevent hotlinking for image url with my domain name and subdomain name , it works well.

    But now, the image URLs in my website all have Optimole CDN links in front, which makes Cloudflare prevent hotlink unable to protect the images with Optimole CDN url.

    If someone applies these images with Optimole CDN url directly to other websites, it will increase the number of visits to my Optimole account.
    How can I refuse the use of image linked to my Optimole CDN by other websites?

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @unbosomjam

    If your site is running on Apache or NGINX, please try the solution mentioned in this guide..

    If you have cPanel access, please follow https://documentation.cpanel.net/display/84Docs/Hotlink+Protection

    Hope it helps and let me know if you require any further assistance.

    Thread Starter 温唯

    (@unbosomjam)

    HI Poonam Namdev @poonam9
    Thank you for replying.
    I have also turn on Prevent Hotlinks through All In One WP Security & Firewall , which will insert code to .htaccess
    But it also protect images with the url from my domain , not includes the url from OptiMole CDN.

    For example:
    Here is an image url with my domain , this url has been protected from hotlink.
    https://mydomain.com/wp-content/uploads/image.jpg

    And here is an image url with OptiMole CDN , this url has not been protected from hotlink.
    https://example.i.optimole.com/example/w:280/h:187/q:100/dpr:2.0/https://mydomain.com/wp-content/uploads/image.jpg

    What I want to ask is, how can I protect the images provided through the OptiMole CDN to prevent them from being hotlinked, because this will increase the number of visits to my OptiMole account.

    Hi @unbosomjam,

    If you can access the code added by the All In One WP Security & Firewall plugin in the .htaccess file, try to add the Optimole CDN URL just like your main domain added to enable the hotlink protection for images.

    Let us know how it goes.

    Thread Starter 温唯

    (@unbosomjam)

    Hi Poonam Namdev @poonam9

    Thank you for helping me.

    The following codes is what I found in .htaccess file
    Sorry to replace the real domain with *mydomain* for some reasons.

    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://mydomain\.com [NC]
    RewriteRule \.(gif|jpe?g?|png)$ - [F,NC,L]

    Can you teach me how to modify the codes?
    For example: when the image url provided by Optimole’s CDN is https://example.i.optimole.com/example/w:280/h:187/q:100/dpr:2.0/https://mydomain.com/ wp-content/uploads/image.jpg, then, what code should I fill in? And where should I insert them?

    Thanks in advanced.

    Hi @unbosomjam,

    Sorry for the delay in response.

    Using htaccess rules won’t help in this case because the optimized images are served from CloudFront CDN and not from your server. Currently, we do not have a solution for this case, but we will check if we can improve to prevent hotlinking for the optimized images.

    Hope you understand. ​Let us know if we can help with anything else.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Prevent hotlinking’ is closed to new replies.