The visual aspect of a website has become significant over the years. As internet speed improved and digital technologies evolved, people started including images and other media to enhance the visual appeal of their interfaces. Most of us spend a lot of time picking and choosing the best photos for our websites. However, there are some users who do not make may efforts in acquiring pictures for their websites. Here we are providing helpful information on how to block image hotlinking in WordPress. These methods will help WordPress website owners in preventing others from using their images in an unauthorized manner. Let us now discuss image hotlinking and how you can detect and stop it on your website.
What Is Image Hotlinking?
Let’s say you are visiting a website and come across a beautiful picture of a pasta dish that is ideal for your food blog. You simply copy the URL of the photo and paste it in your interface. This kind of embedding on a website by linking the picture directly from the original source interface is known as image hotlinking. What seems like an innocuous act is, in essence, wrong and unethical.
When you employ hotlinking then the media element being displayed on your website is still loading from the original source. This means that the valuable server resources of the primary website are being consumed even if no one is visiting it. This can have an adverse impact on the website’s overall performance. Moreover, using someone else’s property without proper authorization is not ethically correct. Another reason why it is not a good practice is that the original owner can remove the image at any time. This means that it will then not be rendered on your interface also.
How To Detect Image Hotlinking On Your Website?
Hotlinking can go undetected most of the time as the server resources consumed may not significantly affect the website performance. However, if you want to know whether someone is using the technique to embed your pictures, then you can use a simple procedure to find out whether you are a victim of the unethical practice or not. Go to the Google Images website and paste the following command in the search box:
Do not forget to replace “example.com” with your domain. Press enter and wait for the search results to be populated. What this command does is exclude your URLs from all the results and show only other locations that contain your images. An important point to note here is that this method only displays your media elements on other interfaces. The results also contain items that have not been hotlinked. An in-depth analysis will require you to hire a WordPress designer. However, it is a quick way to know whether you are losing resources because of the hazard or not.
How To Stop Image Hotlinking In WordPress?
Let us now discuss the ways to block image hotlinking in WordPress. We are providing 4 different methods and you can use one that suits you.
1. Modifying The .htaccess File
Before using this method take a backup of your website as a precautionary measure. The .htaccess file defines how the Apache server interacts with a WordPress website. You can modify it to determine the URLs that can access your image files. Connect to your website through an FTP client. Locate the root folder which usually is named public_html. Find the .htaccess file inside it.
Open the file in a text editor and add the following code right at the end:
Here we have defined that apart from Google, Facebook, and Twitter, no other entity can access our domain “example.com”. Make sure you replace it with your domain name. The last line has been used to define the image formats on which the rule will apply. See the line with “..other-websites-go-here”. You can use the format to exclude other URLs from the blocking. Save and upload your file to finish the process.
2. Activating The Hotlinking Protection Feature in cPanel
You can turn on the hotlinking protection feature from your cPanel to stop others from accessing your pictures. Access your cPanel and go to the Security section. Here you will find the Hotlink Protection option.
Click to open it and then enable the feature. Now you will have to enter all the URLs that should be given access and provide the relevant image file types. Press Submit to activate hotlink protection on your website.
3. Using A Security Plugin
In case, you feel tinkering with an important file will not be possible, you can use a security plugin that has a feature to stop hotlink. A popular plugin that you can use this purpose is All In One WP Security & Firewall. Besides a range of other security features, it can help you prevent image hotlinking by simply choosing the relevant option.
4. Blocking Image Hotlinking Through CDN
Another effective way to resolve the issue without writing any code is to subscribe to a CDN service that offers the necessary feature. Many prominent CDNs provide an inbuilt feature for hotlinking protection. Using a CDN for the purpose is an efficient way to solve the problem as they have a well-defined rules system for allowing only the important and relevant bots from traversing a website.
These are some simple methods to prevent image hotlinking on your website. You can also hire a WordPress web development expert to identify the best approach and implement the relevant preventive measures.
Brandon Graves is a WordPress expert working with HireWPGeeks, a company that can be contacted to hire WordPress designers. He likes to explore different kinds of topics related to WordPress web development. Follow Brandon on Twitter to get updates about more valuable information.