Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    Germany
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Redirecting google images with htaccess?

    Hey everyone,
    I'm pretty new to the world of coding so please bear with me. On another forum a webmaster came up with a brilliant idea. In order to avoid losing traffic (and possibly revenue) via google images he did a rewrite in htaccess that breaks your website out of the google images frame. So anyone who finds an image on your website is redirected to a specific page when clicking on the thumbnail or "see full sized image". Im sure most here get a lot of traffic from google images but unfortunately visitors often only download the image via the frame instead of checking out the website. This rewrite avoids that. Here's the code - kudos go to that webmaster.

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?YourDomain\.com [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule \.(jpeg|jpg|gif|bmp|png)$ http://www.YourDomain.com/ [L]
    On the last line the url can be aynthing you like. Now my problem is this: I want to send visitors to each specific page of each specific image. This code unfortunately doesn't allow for that and the webmaster told me it's not possible to summarize several individual image redirects in one htaccess. Is that true?

    The only way he figures is that one would have to place an htaccess into each image folder using the above code and changing the last line to the specific page url. That would be a lot of work because I'm running a wordpress blog and there the images are arranged in monthly folders. So I would have to make an image folder for each specific page and shift the appropriate files there. And then I would have to redo all the image links from my individual pages. So I really am looking for a way of just using one single htaccess (placed in the uploads folder which contains all the monthly subfolders). I tried the following and it didnt work:
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain\.com/wp-content/uploads/2009/04/xxx.jpg [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule \.(jpeg|jpg|gif|bmp|png)$ http://www.yourdomain.com/page-with-xxx-image [L]
    I also tried simple 301 redirects in the same manner and that didn't work either. E.g.:
    Code:
    redirect 301 /wp-content/uploads/2009/04/xxx.jpg http://www.yourdomain.com/page-with-xxx-image
    Would a 301 image redirect actually work? I'm afraid that it would eliminate the picture from google images or maybe even from the page itself?

    I hope you guys can help me, I really would like to do this. A lot of my traffic comes via google images but the bounce rate is extremely high there. And in case there's a moral discussion about this, I don't see anything wrong with it. I know there is a javascript for this that google penalizes you for, but this should be ok. The webmaster I mentioned has been implementing his htaccess redirect for quite some time without any penalty. However I don't like that he sends visitors to "some" page and not the specific image page. That to me is questionable, hence my insistence on doing the redirects to each corresponding image page. Thanks ya'll!

  • #2
    New Coder
    Join Date
    May 2009
    Location
    Germany
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Anyone? Btw, I found a way to disable the monthy image folders in Wordpress. Under settings and miscelaneous there's a box that can be unchecked. Well, I guess I will start shifting the page specific images into their own folders if nobody here knows a better way to make this work.

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    356
    Thanks
    0
    Thanked 16 Times in 16 Posts
    Now my problem is this: I want to send visitors to each specific page of each specific image. This code unfortunately doesn't allow for that and the webmaster told me it's not possible to summarize several individual image redirects in one htaccess. Is that true?
    Is it always the same format URL (different dates) before and after, ie.
    Code:
    /wp-content/uploads/2007/01/xxx.jpg /page-with-xxx-image
    /wp-content/uploads/2008/02/yyy.jpg /page-with-yyy-image
    /wp-content/uploads/2009/03/zzz.jpg /page-with-zzz-image
    or does "page-with-" and/or "-image" change, ie.
    Code:
    /wp-content/uploads/2007/01/xxx.jpg /page-with-xxx-image
    /wp-content/uploads/2008/02/yyy.jpg /another-page-with-yyy-image
    /wp-content/uploads/2009/03/zzz.jpg /some-page-with-zzz-image
    ?

    The first can be done with a single rule, the second would require seperate rules or a combination of mod_rewrite and PHP (for example).

  • #4
    New Coder
    Join Date
    May 2009
    Location
    Germany
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It's like in the second example. I have pretty permalinks for every page. I went ahead now anyway.

    I restructured all my image folders by creating a folder for each page and placing the corresponding images in there. Then I did an htaccess for each page and placed it in the folder. Works great! The only problem is that google images first took out those images from the search but it took only about one or two days until they were readded. So google seems to have no problem with this. As for the actual relocation of the images, google needs longer (one to two weeks).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •