Forum Moderators: phranque

Message Too Old, No Replies

Redirect JPG to php

         

Nosfer

10:45 pm on Jan 31, 2009 (gmt 0)

10+ Year Member



Hey,

i have a wordpress blog that gets a lot of visits daily from Google Images [like 1-2k/day] and most of those visits click fast on "View large size" and i can't monetize those visits. I made an image.php that will include the image, some text and ads and now i need to find a way to redirect .jpg to image.php?=image.jpg

The images are stored in multiple folders like:

http:// site.com/wp-content/uploads/2008 & 2009/01 to 12/

Anyone knows the solution for that?

[edited by: Nosfer at 10:46 pm (utc) on Jan. 31, 2009]

g1smd

11:36 pm on Jan 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you need a redirect or a rewrite?

Think very carefully before answering.

Explain why you think you need the one you think you need.

Defining 'what' you want and 'how it works' is the major time-consuming part of the solution. The coding is trivial after that.

Nosfer

12:02 am on Feb 1, 2009 (gmt 0)

10+ Year Member



I think i might need a rewrite. Visitors click on the "view large size" link from Google Images and they go to the .jpg file so... i would need them to go to that image.php.

jdMorgan

12:36 am on Feb 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, you really need to change the links on your pages so that "View large size" links to a "page" URL, instead of an image URL. Otherwise, you may fool search engines (and users) into linking to what they think is an image file. But since it's an HTML page, this may malfunction.

So, best practice would be to link "View large size" to /wp-content/uploads/2008-2009/01-12/lg-image-001234.html, and then rewrite that (using mod_rewrite) to /image.php?image=uploads/2008-2009/01-to-12/lg-image-001234.jpg or some-such. (Note that I got rid of all characters in those URLs that are required to be hex-encoded before they can be included in a URL, such as spaces and ampersands. See HTTP specification RFC2396 for more info.)

Basically, if you are going to include a "file type" in a URL, it is best if that filetype is accurate. For some background on why I recommend this, try searching for "link to page instead of image" and similar; The basic problem is that browsers can't handle HTML when they're expecting an image-format file, because a "page" usually defines a "whole new window" in a browser, while an image is usually included into the current window.

Jim

Nosfer

12:59 am on Feb 1, 2009 (gmt 0)

10+ Year Member



ah Jim! i was waiting for a good answer from you. i came to this forum from a google search for the same thing and saw you know a lot of things about redirects and thought to ask my problem here.

The "View large size" link is not on my site, it's on the google Images frame. For example:

[images.google.com...]

when you click on an image on the top frame it has a "view large size" link which takes the visitors to the .jpg file. I use a redirect script from top location to post location but it's too slow and still loose a lot of visitors.

jdMorgan

2:14 am on Feb 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ugh. This may require a redirect, then. I would suggest trying this with a single image link before committing to this approach.

Jim