homepage Welcome to WebmasterWorld Guest from 54.234.147.84
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
How to redirect Google images queries?
ichthyous




msg:1510296
 4:08 pm on May 12, 2006 (gmt 0)

Hi there, I am a photographer and discovered today that Google has indexed about 1K of my images from my site quite nicely, with better descriptions than Google search has for the pages they are located on. The problem is that since my pages are dynamic and I have been making quite a few category/subcategory changes, most of the URLs indexed in Google Images are no longer valid. When a user clicks on the image the user gets a automatically generated "this product no longer exists" message. I need a simple redirect code which will redirect all google images traffic to my home page. Thanks for any help!

 

jdMorgan




msg:1510297
 6:05 pm on May 12, 2006 (gmt 0)

You could probably use a mod_rewrite RewriteCond directive to test %{HTTP_REFERER} and then redirect all image-type requests to another (defined) image. It all depends on what one of these requests looks like.

Do you have a sample from your raw server access log? (Please obscure any uniquely-identifiable info -- e.g requestor IP addresses, domain names.)

Jim

ichthyous




msg:1510298
 7:52 pm on May 12, 2006 (gmt 0)

Here is a sample of a hit from images.google.com:


200.85.***.50 - - [12/May/2006:09:15:04 -0400] "GET /Qstore/Qstore.cgi?CMD=011&PROD=1022544466 HTTP/1.0" 200 10606 "http://images.google.com.co/imgres?imgurl=http://www.mysite.com/Qstore/upl/agrocampo2.jpg
&imgrefurl=http://www.mysite.com/Qstore/Qstore.cgi%3FCMD%3D011%26PROD%3D1022544466&h=218&w=325&sz=27
&tbnid=nx7aeD-utJbNfM:&tbnh=76&tbnw=114&hl=es&start=15
&prev=/images%3Fq%3DAGROCAMPO%26svnum%3D10%26hl%3Des%26lr%3D%26rls%3DGGLG,GGLG:2006-10,GGLG:es%26sa%3DN" "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"
200.85.***.50 - - [12/May/2006:09:15:05 -0400] "GET /Qstore/upl/agrocamp.jpg HTTP/1.0" 200 2134
200.85.***.50 - - [12/May/2006:09:15:05 -0400] "GET /Qstore/upl/agrocamp.jpg HTTP/1.0" 200 2134 "http://images.google.com.co/imgres?imgurl=http://www.mysite.com/Qstore/upl/agrocamp.jpg
&imgrefurl=http://www.mysite.com/Qstore/Qstore.cgi%3FCMD%3D011%26PROD%3D1022544466&h=218&w=325&sz=27
&tbnid=nx7aeD-utJbNfM:&tbnh=76&tbnw=114&hl=es
&prev=/images%3Fq%3DAGROCAMP%26svnum%3D10%26hl%3Des%26lr%3D%26rls%3DGGLG,GGLG:2006-10,GGLG:es%26sa%3DN
&frame=small" "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"

thanks

[edited by: jdMorgan at 1:20 am (utc) on May 13, 2006]
[edit reason] Obscured specifics, fixed side-scroll [/edit]

jdMorgan




msg:1510299
 1:33 am on May 13, 2006 (gmt 0)

It looks like testing %{HTTP_REFERER} would do it, possibly combined with a test of %{QUERY_STRING} to make the rule more specific (if you have other image URLs that you *do* want Google images to work with).

Jim

ichthyous




msg:1510300
 1:56 am on May 13, 2006 (gmt 0)

I don't know how to write the code myself, only to modify it slightly...would this take a lot of code to make work? I tried putting a 301 redirect in both my htaccess and httpd.conf file to redirect a couple of the invalid URLs but it didn't work.

ichthyous




msg:1510301
 4:59 pm on Jun 1, 2006 (gmt 0)

JD is there a way to simply redirect ALL incoming traffic from images.google.com to one page? With this latest big daddy update traffic to my pages has plummeted but image searches are much stronger...possibly also becaused i went through and renamed my images and made sure they all had meta tags. The problem is the individual pages these images are embedded in are long gone. Google has 835 images indexed from my site and most of them link to dead pages. I simply want to reroute them all to my home page where they can search for the image if they want. Is there a simple way to reroute all traffic from one URL? Thanks

jdMorgan




msg:1510302
 8:09 pm on Jun 1, 2006 (gmt 0)

You can't redirect an image request to an hTML page -- The browser expects an image, and the HTML mechanism used to load images is completely different from that used to load pages. So, as I posted above, you could redirect all G image requests to a single image, or redirect each image to its replacement's URL, the latter being the best approach if you really have to change your URLs.

We can't write code on demand here -- the demand would simply be too great for the limited number of contributors here to keep up with. We'll be happy to answer specific questions to help you get started learning to do it yourself, though. A good place to start is with the documents cited in our Forum Charter [webmasterworld.com]. Alternately, a search on WebmasterWorld may turn up some previously-posted code to serve as an example.

Jim

ichthyous




msg:1510303
 8:38 pm on Jun 1, 2006 (gmt 0)

Google images doesn't index only the images...it indexes the HTML pages where the images are located. Google doesn't send people directly to the image, but rather the page itself where it was embedded...presumably becuase they might get into a heap of copyright trouble otherwise.Here is a typical google images URL:
http://images.google.com/imgres?imgurl=http://www.mysite.com/Qstore/uploads/sagfamwin.jpg&imgrefurl=http://www.mysite.com/Qstore/Qstore.cgi%
3FCMD%3D011%26PROD%3D1019662770&h=324&w=229&sz=34&hl=en&start=1&tbnid=c0SFBs8jlpas9M:&tbnh=114&tbnw=80&prev=/images%3Fq

So basically when people click the top frame of the google image search results page which shows the image directory URL on my server it's fine since the image hasn't moved, but the actual page where it can be found (the bottom frame of a Google image search) is what can't be found. I am not concerned with people not being able to find the JPEG, but rather the page where the JPEG is embedded. Keeping that in mind would it still be impossible to route them seeing that the URL is bifurcated?

ichthyous




msg:1510304
 8:41 pm on Jun 1, 2006 (gmt 0)

maybe a simpler question: is it possible to redirect all traffic from a subdomain of google (images.google.com) to my home page, or would that code then redirect ALL google.com traffic to my site to the home page?

jdMorgan




msg:1510305
 9:24 pm on Jun 1, 2006 (gmt 0)

Yes.

RewriteCond %{HTTP_REFERER} ^http://images\.google\.com/imgres\?imgurl=http://www\.[i]mysite\.com[/i]/Qstore/uploads/
RewriteRule ^Qstore/(Qstore\.cgi¦upload/[^.]+\.jpg)$ http://www.[i]mysite.com[/i]/ [R=301,L]

Change the broken pipe in the RewriteRule pattern to a solid pipe before use; Posting on this forum modifies pipe characters.

Jim

ichthyous




msg:1510306
 7:35 pm on Jun 7, 2006 (gmt 0)

unfortunately it doesn't work...I'm not trying to redirect the uploads folder...those are fine. I'm trying to redirect any hits to the dynamic pages back to my home page. I'm not sure why the references to the uploads folder is there...please explain

jdMorgan




msg:1510307
 12:28 am on Jun 8, 2006 (gmt 0)

...because you included log entries with 'uploads' in them above, and I don't know your site.

So what specific URL-paths do you want to rewrite?

Jim

ichthyous




msg:1510308
 12:59 pm on Jun 8, 2006 (gmt 0)

I want to redirect all links from google images to [mysite.com...] theis could include 800+ specific URLS, so I don't want to redirect individual URLs, just the whole shebang. If it's easier to redirect all google image requests to just [mysite.com...] then we can do that too. The problem is that Google has very outdated links from last year indexed for my site. While i am waiting for Google to sort out it's indexing probs I am losing a ton of image search traffic everyday because the linked pages don't exist anymore.

jdMorgan




msg:1510309
 9:54 pm on Jun 8, 2006 (gmt 0)

Using this log entry:

200.85.***.50 - - [12/May/2006:09:15:05 -0400] "GET /Qstore/upload/agrcamp.jpg HTTP/1.0" 200 2134

We'd get:

RewriteCond %{HTTP_REFERER} ^http://images\.google\.com/imgres
RewriteRule ^Qstore/upload/[^.]+\.jpg$ http://mysite.com/Qstore/Qstore.cgi [R=301,L]

Jim

ichthyous




msg:1510310
 7:44 pm on Jun 9, 2006 (gmt 0)

No this still isn't working...should this be placed in the htaccess file in the root level or in the Qstore directory?

jdMorgan




msg:1510311
 8:45 pm on Jun 9, 2006 (gmt 0)

As written, it would go at Web-root level, since "Qstore/upload/" is included in the RewriteRule pattern.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved