Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I wanted to set up my .htaccess file so that people who hotlink my images would not be able to display may images and instead a "STEALING IS BAD" image would show up instead.

I tried to put the follwowing code into my root's .htaccess file, but it doesn't do anything. Any ideas how I'd have to modify the code any further to make it work?

[....]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?zoomingjapan.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds.feedburner.com/ZoomingJapan [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ ? [NC,F,L]
#RewriteRule \.(jpg|jpeg|png|gif)$ http://zoomingjapan.com/../hotlinking.png [R,L]
</IfModule>

# END WordPress

Thanks a lot in advance.

share|improve this question

migrated from wordpress.stackexchange.com Nov 1 '11 at 18:18

This question came from our site for WordPress developers and administrators.

    
This is an .htaccess question, not a WordPress development question. –  Chip Bennett Nov 1 '11 at 14:59
    
Uhm. Sorry, I see. I didn't know about that. I'm still quite new when it comes to all this and I thought .htaccess was something unique to Wordpress. So, where would I post about it then? –  japanworm Nov 1 '11 at 15:05

1 Answer 1

This here looks like you need to un-comment that in order for the image replacement to work.

#RewriteRule \.(jpg|jpeg|png|gif)$ http://zoomingjapan.com/../hotlinking.png [R,L]
share|improve this answer
    
Hello and thank you very much for your answer. I'm quite new to all of this, so I don't understand what you mean by "un-comment". Could you elaborate? Thank you :) –  japanworm Nov 1 '11 at 23:54
    
Ok to un-comment that line just remove the "#" from the beginning of the line. –  Nicole Nov 2 '11 at 13:54
    
Thank you. The code worked kind of. That means the "stop hotlinking" image is now properly showing up, however it also replaces ALL of the graphics I'm using on my website, even on the main page (index.php) although I set it as a rule that it should exclude my domain from it. Any ideas why? –  japanworm Nov 2 '11 at 14:41
    
I am going to assume that since you are using wordpress you are using full urls to link your images (example: yoursite.com/image.jpg ). For your images inside your theme you should use /wp-content/themes/your-theme/images/yourimage.jpg . This way it should (i am not sure) not constitute as or trigger the hotlinking with in your own site. I am not sure but it is worth a shot. –  Nicole Nov 3 '11 at 14:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.