Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Consultant

macrumors G5
Original poster
Jun 27, 2007
13,314
36
Someone posted a URL to a image on my server. It's NOT embedded / hotlinked, but uses bandwidth when they click on the link and see the image.

I want visitors from that site to see the actual article instead.

Can I use htaccess to redirect www.my.com/image/file.jpg
to a page www.my.com/post, based on referrer of www.site.com/blah

Do I have to use the hotlink protect?
 
no you cannot redirect them. Just create an image with a message to come visit your website to view the original image instead.
 
You can use the rewrite to redirect to another image that has a watermark promoting your site or the article.
 
I don't believe you can redirect to an actual page.. but you can have another image swapped in on the fly:

http://altlab.com/htaccess_tutorial.html

That was just the first link I clicked on after searching for 'htaccess hotlinking' - and indeed, hotlinking is the keyword for what you are trying to stop.

Of course it comes with the warning that some people behind firewalls may have trouble even when on your site directly. Unless your host hardly gives you any bandwidth, I doubt this would cause that big of a troubles, compared to a movie file or such... Perhaps it's better for all to simply write the website and demand they give a source link to your page under the image [helps boost your ranking/traffic/etc]
 
From your description that sounds like hotlinking. It links directly to your site and is using your bandwidth. Mod rewrite does have a "type" (as in mime-type) option to force a new mime-type that could be used to redirect to a different kind of file, but this won't redirect the user, only redirect the site's request for the image. So I don't know that it will really help in what you want. I just block hotlinking and deliver a "thief" image.

Small sampling example
PHP:
RewriteRule .* - [T=text/html]
 
I came upon some info saying cPanel can redirect to a page under "hotlink" settings, but don't see it in my current cpanel.

Basically, someone posts this in a comment:


I guess that's still considered hotlinking still even if it's not embedded?
 
I guess that's still considered hotlinking still even if it's not embedded?

I see what you mean now. That's isn't hotlinking, just linking. I thought the page had <img src="www.my.com/image/file.jpg" />, which causes the image to show up on their page without needing to visit yours.

In that case the redirects should work. You would use the same basic setup that is done for hotlinking though, and adjust the mime-type as you redirect to a html-based page. I've never done this personally so can't give a 100% working example. If I get a chance I'll try some things locally.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.