Forum Moderators: phranque
apart from now linking to my site its not stopping the leaching can anyone tell me why i'm doing wrong?
Welcome to WebmasterWorld [webmasterworld.com]!
First, let's clean it up a bit and see if that helps. You've got two identical lines in there, and the Rule itself is, um, messy... ;) Also, you cannot redirect from an image file to an html page - it won't work, and would just use up your bandwidth anyway, even if it did work.
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule \.(gif¦bmp¦jpe?g)$ - [NC,F]
Change all broken pipe "¦" characters above to the solid pipe character before use -- usually, it's Shift - \ on your keyboard.
If this doesn't help, please repost and say what it does and does not do. Remember to flush your browser cache (Temporary Internet Files) while testing. (If an image is already in your cache, then it will appear that your access was not blocked, because the image will be loaded from your local cache, and not from your server. If the image is not requested from your server, then .htaccess can't block it.)
Ref: Introduction to mod_rewrite [webmasterworld.com]
Jim
thanks again
> Am i right in thinking that the .co.uk comes after the \?
Well, yes and no...
Any time you want to match a literal period in regular expressions notation, you must precede it with a backslash, otherwise, a period means "any single character". The "^" character is a "start anchor" and thus requires an exact match at the beginning of the string being compared against the pattern. Similarly, the "$" character is an end anchor, requiring an exact match at the end of the pattern. Using both anchors specifies an exact string-to-pattern match, nothing more, nothing less. Thus, the URL "http://members.widgetclub.co.uk/login.php" would be written as "^http://members\.widgetclub\.co\.uk/login\.php$". The pattern I gave you in the post above intentionally omits the end anchor in the RewriteCond testing the referrer, and uses only the end anchor in the RewriteRule.
Follow the link I cited above and look for the link to the regular expressions tutorial cited in that post; Using mod_rewrite without a thorough understanding of regular expressions syntax and notation can be extremely frustrating, and possible dangerous to your site (Said with your best interest in mind and apologies for the apparent bluntness of communication in this medium).
Please let us know how this works out. If you still have problems, please try to capture the relevant log entries from your server error log -- they are often of great help in figuring out the exact problem.
Jim
To be really cheeky is there a way of locking images within front page? to stop the being taken in the first place.
thanks again
tattyfan
> is there a way of locking images within front page - to stop them being taken in the first place?
No, anything you post on the web can be abused. The idea is just to make it more difficult, so that most troublemakers will move on to easier targets. If you don't want it copied (at all), don't put it on the Web.
Interestingly, I got "attacked" last night for the first time in several years - hundreds of image requests for two images hot-linked from a discussion forum for one of the two most popular video-gaming consoles. Thankfully, after several hundred 403 errors over the course of an hour, the poster finally figured out that his post was showing broken images and de-linked them -- The log files are a mess!
On a more popular site, this could have been a real problem. So, the anti-hotlink code worked on my end... Glad it worked for you, too!
Jim