Title: Successfully adding Anti Hot linking code
Last modified: August 19, 2016

---

# Successfully adding Anti Hot linking code

 *  [Mobbin01](https://wordpress.org/support/users/mobbin01/)
 * (@mobbin01)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/successfully-adding-anti-hot-linking-code/)
 * I have been trying to get the following code to work with no success:
 * # anti-hotlinking
    RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond%{
   HTTP_REFERER} !^http://www.mysite.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^
   http://mysite.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !google\. [NC] RewriteCond%{
   HTTP_REFERER} !yahoo\. [NC] RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
   RewriteCond %{HTTP_REFERER} !search\/cache [NC] RewriteCond %{HTTP_REFERER} !
   cache [NC]
 * RewriteRule .*\.(jpg|JPG)$ [http://www.mysite.com/images/hotlinked-image.jpg](http://www.mysite.com/images/hotlinked-image.jpg)[
   R,NC]
 * Should I add this to my root .htaccess file, and if so can I add it just like
   this at the end after this code:
 * <IfModule mod_rewrite.c>
    RewriteEngine On RewriteBase / RewriteRule ^index\.
   php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}!-
   d RewriteRule . /index.php [L] </IfModule>
 * Or do I have to add the <ifmodule mod rewrite.c> around the hotlinking code? 
   or add # BEGIN or # END
 * also, there are .htccess in wp-content and wp-admin. Should the code go to any
   of these other places?

The topic ‘Successfully adding Anti Hot linking code’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Mobbin01](https://wordpress.org/support/users/mobbin01/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/successfully-adding-anti-hot-linking-code/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
