Redirect image to page?

Discussion in 'Web Design and Development' started by Consultant, Feb 9, 2011.

  1. Consultant macrumors G5

    Consultant

    Joined:
    Jun 27, 2007
    #1
    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?
     
  2. manueld macrumors 6502

    Joined:
    Jun 8, 2009
    #2
    no you cannot redirect them. Just create an image with a message to come visit your website to view the original image instead.
     
  3. Laird Knox macrumors 68000

    Joined:
    Jun 18, 2010
    #3
    You can use the rewrite to redirect to another image that has a watermark promoting your site or the article.
     
  4. needlnerdz macrumors regular

    needlnerdz

    Joined:
    Jun 10, 2006
    Location:
    switzerland
    #4
    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]
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    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]
     
  6. Consultant thread starter macrumors G5

    Consultant

    Joined:
    Jun 27, 2007
    #6
    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?
     
  7. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #7
    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.
     

Share This Page