Prevent Image Hotlinking but Allow Google to Show in the Search Results

The more you publish the content, the more are the chances that people will try to steal it. Images are the important parts of your blog posts and you should prevent image hotlinking but allow Google for safety.

Have you noticed anyone using your images in their blog posts? Have you taken any step to prevent image theft?

Well, in this article, you will learn the concept of image hotlinking and how can you stop people to use your images.

Let me tell you that image hotlinking is a very advanced concept about which most of the WordPress users aren’t aware.

How would you feel when someone uses your space to showcase their talent and you don’t get any credit? Image hotlinking is similar to this.

What is Image Hotlinking in WordPress

When someone copies the image you have created for your blog post along with the URL of those images and uses on his/her own blog.

It means the person has hotlinked those images to your blog.

What do you understand by that? It means whenever someone visits to their blog, the images will get uploaded from your server.

It will consume the bandwidth of your web hosting.

Isn’t that similar to the situation I have mentioned above? Hell yeah, people are really tricky and most of the WordPress users think it’s just the image theft.

They don’t even have an idea that it’s also the theft of the money they pay for their web hosting. Those images will consume it which can affect your website to a greater extent.

I know it can be scary but don’t worry, you can prevent image hotlinking but allow Google to index those images so that you can get the proper benefit of the search engine.

How to Stop Image Hotlinking in WordPress

You can have the solution to every solution at this amazing platform.

There is a good new for you. You can stop people for image hotlinking by adding a code in the .htaccess file of your website.

For which, you should know how to edit the .htaccess file.

There are basically two ways. If you’re a Yoast SEO plugin user then it can be done from the WordPress admin panel only.

Go to SEO>>Tools and you will “File Editor” option which can be used to edit the robots.txt and the .htaccess files.

Though not everyone is using this SEO plugin so you can do that by using your web hosting account.

Login to your cPanel account and go to files>>file manager>>.htaccess file.

NOTE: Don’t forget to check the box to display the hidden files because the dot as the prefix for the .htaccess file signifies that it’s a hidden file.

Can’t find the .htaccess file? Create a new one.

Open this file to edit and add this code.

# Disable image hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?example.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?google.com [NC]
RewriteRule .(jpg|jpeg|png|gif)$ – [NC,F,L]

NOTE: Don’t forget to change “example.com” with your domain name.

Save the file and you have successfully blocked people for image hotlinking.

If someone tries to steal your image along with the original source, the images wouldn’t appear. Everyone will see 403 forbidden error.

It’s because no one else has the permissions to use the images of your blog.

If you’re not comfortable then you can use All in one security plugin by enabling a simple option. The plugin has a built-in feature to disable right-click for the content of your website including images.

Can You Now Prevent Image Hotlinking but Allow Google to Show Images in the Search results

With the growing blogging network, you have to take care of such things. People are looking for some vulnerabilities and this is the one.

Image hotlinking can make your website slow and you wouldn’t even know about it. That’s why it’s recommended to keep enabling trackbacks and pings so that you can come to know when someone links to your blog.

To prevent image hotlinking but allow Google, you just have to use the above-mentioned code and you’re done. If you have any doubt, feel free to clear it.

You can also connect with us on Twitter, LinkedIn, and Facebook.

by Ravi Chahar

A WordPress Professional and the LinkedIn Influencer. A coder by passion and a blogger by choice. WordPress theme development is his forte. He is your WordPress guy who will teach you how to solve WordPress errors, WordPress security issues, design issues and what not.

Get Free Updates Into Your Inbox

Learn Everything Just Like I Did

SUBSCRIBE

4 comments

  1. Ravi, I love this one. What a great idea. Do the people who do that get punished by Google for duplicate content at all?
    Sometimes it can be hard to tell what is real or not with images. I sometimes take a lot of photos to use in blog posts to avoid that one.
    Thanks for sharing this one with us today!

    1. Hey Lisa,

      Google is smart but sometimes it doesn’t come to know about the duplicate content until the author file a complaint. And stealing images is so common but image hotlinking is the worst.
      It’s always good to create your own images and add a copyright tag.
      Thanks for your input.
      ~Ravi

  2. Hi Ravi,

    Thanks for sharing this and for showing us how to prevent image hotlinking. This is a scary thought.

    Thankfully, I haven’t had this happen to me but it’s always better to be safe than sorry.

    I’m hanging on to this post so I can add this code! No doubt I’m passing this along. ?

    Have a great day Ravi!

    Cori

  3. Hey Ravi,

    Hotlinking is a serious threat to websites using shared web hosting as we have limited resources available.

    On the flip side, if you’re on a cloud host, it’ll have little to no impact given that someone’s not willingly doing it to harm your site.

    Thanks for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *