This script is placed in the file. Htaccess, but to access these file you must have access to the admin panel in the hosting. This file will be exactly one level with the folder wp-admin, wp-includes, wp-content. If you do not find this file, first make sure you have show the hidden files, if the file is not exists, you can create this file directly on your hosting by click create a new file with the name ". Htaccess" without the quotes. Well here are the default script file. Htaccess, please copy and paste the file into .Htaccess file that you just created.
# BEGIN WordPressRewriteEngine On RewriteBase /wordpress/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L] # END WordPress
Now you have the file. Htaccess. Then the anti-hotlinking script, please copy and paste the following code into the file. Htaccess.
RewriteEngine On #Replace ?mysite\.com/ with your blog url RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ #Replace /images/nohotlink.jpg with your "don't hotlink" image url RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]
So now your .Htaccess file will be look like this.
Do not forget to replace ?mysite\.com/ with your domain name, then /images/nohotlink.jpg with your "no hotlink" image. URL address of the image is /images/xxx.jpg, so make sure you have folder "images" in there. You can make it or you can change it to another address, such /wp-content/uploads/2013/nohotlink.jpg.
That's it the tutorial of how to protect your WordPress blog from hotlinking using .htaccess, now you can try to put your image link on another blog and see what happened. Happy blogging.
0 comments:
Post a Comment