Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set hotlink protection for WordPress images

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to set up the hotlink protection of WordPress pictures, I believe most people don't know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's go to know it together.

How to set hotlink protection for WordPress images?

If your blog has a lot of pictures, and there are traffic restrictions, it should be said that it is imperative to prevent others from stealing their own picture links, because in China, the phenomenon of blog content copying each other is quite common. We all cherish their own little bit of space, directly copy pictures (copy is with links, oh! (like a home-cooked meal, it has become commonplace. Picture hacking will not only consume your space traffic quickly, but also affect the page loading speed of the website!

There are many ways to set up image hotlink protection on the Internet, here are two, one is to use the .htaccess file to make some simple settings can easily prevent others from stealing the links of the original images on their own site; the other is to use the plug-in WP Hotlink Protection.

one。 Modify the .htaccess file

How do you do that? First create a small picture as a warning. You can type "Please do not hotlink from my server" on this picture (which probably means: don't steal my picture link! ) such a warning. Then upload the picture to your own space server and remember the path where the picture is stored.

Then open the .htaccess file in the root directory of the WordPress website, and the original content should be something like this:

# BEGIN WordPressRewriteEngine OnRewriteBase / RewriteRule ^ index\ .php $- [L] RewriteCond% {REQUEST_FILENAME}!-fRewriteCond% {REQUEST_FILENAME}!-dRewriteRule. / index.php [L] # END WordPress

The code after adding hotlink protection rules is as follows:

# BEGIN WordPressRewriteEngine OnRewriteBase / RewriteRule ^ index\ .php $- [L] RewriteCond% {REQUEST_FILENAME}!-fRewriteCond% {REQUEST_FILENAME}!-dRewriteRule. / index.php [L] RewriteCond% {HTTP_REFERER}! ^ http://(www\.)?sayblog.me(/)?.*___FCKpd___1nbsp; [NC] RewriteCond% {HTTP_REFERER}! ^ http://(www\.)?google.com(/)?.*___FCKpd___1nbsp; [NC] RewriteCond% {HTTP_REFERER}! ^ http://(www\.)?baidu.com(/)?.*___FCKpd___1nbsp; [NC] RewriteCond% {HTTP_REFERER}! ^ http://(www\.)?image.baidu.com(/)?.*___FCKpd___1nbsp; [NC] RewriteCond% {HTTP_REFERER}! ^ http://(www\.)?yahoo.com(/)?.*___FCKpd___1nbsp; [NC] RewriteRule. *\. (gif | jpg | jpeg | bmp | swf) $http://www.sayblog.me/images/defaultimage.gif [Rmaine NCJL] # END WordPress

The green part is the rule added by yourself, and the URL should be changed as needed. They belong to the URL that allows the use of pictures.

It is worth noting that there is a difference between the first-level domain name and the second-level domain name, such as the URL above. We have added baidu.com, and we should also add image.baidu.com, so that image.baidu.com will not find the image of hotlink protection.

The main purpose of the added code is to determine whether the link is stolen. If the request to access the image is neither from the URL entered directly, nor from sayblog.me itself, nor from the website in the list, then perform the following redirection:

RewriteRule. *\. (gif | jpg | jpeg | bmp | png) $http://www.sayblog.me/images/defaultimage.gif [RMagneNCmael]

It means that all the pages of gif, jpg, jpeg, bmp, png and swf files under the pirated www.sayblog.me website will be replaced with the logo_sm.gif images in the / ad-img/ directory.

Explain what R, NC and L mean:

R means to turn.

NC means case-insensitive.

L indicates that this turn is over, and the subsequent turn is not affected by the previous judgment statement.

Finally, modifying the .htaccess file to prevent images from being stolen is not suitable for all hosts, such as windows hosts; another drawback of this approach is that it may affect RSS subscribers to read your article, because the pictures in RSS will be displayed as the one used for hotlink protection.

two。 Install the plug-in WP Hotlink Protection (recommended method)

The WP Hotlink Protection plug-in is easy to use and easy to install. It can protect against hotlinks without affecting the access of RSS users. Download address: http://wordpress.org/extend/plugins/wordpress-automatic-image-hotlink-protection/.

Brief instructions, as shown in the figure above:

1.Url Patterns to protect: fill in the path of the image to prevent being hacked.

2.Use a custom image: this item is used to set another picture to be displayed when the picture is stolen (you need to customize one by yourself). Tick on the box to enable this feature.

3.Information image: fill in the path of the image used for hotlink protection here.

There are many websites or blogs that do not have picture hotlink protection, which should be decided according to the limit of traffic and bandwidth of the space server used by each person. if you are in China, the restrictions will be more stringent, especially for some websites with more pictures, it is necessary to prevent pictures from being stolen. If it is a foreign server, most of the traffic is unlimited, unlimited bandwidth, if there are not a lot of pictures, you can rest assured, but it is not absolute, at least there is a limit on CPU utilization.

The above are all the contents of the method of setting up hotlink protection for WordPress pictures. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report