canadabeeau Posted December 20, 2009 Share Posted December 20, 2009 Now as you would know usually when you visit an image via URL you get like just the image, now I want to make it so when people either via google images etc. visit that images URL they not only get the image but a webpage with the image in it, any ideas?? seson greetings and thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/ Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 Well, if they are visiting an images URL directly - you can't inject any logic into that. The only point of access that you have to control where people go would be from mod_rewrite in your apache configuration. Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980787 Share on other sites More sharing options...
canadabeeau Posted December 20, 2009 Author Share Posted December 20, 2009 When I find the image website that does it I'll post the link, cant remember the name of the site now :-( Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980793 Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 I can tell you that if the link doesn't end in image.php, they aren't using php to redirect you to something else. That is in the web server config. Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980794 Share on other sites More sharing options...
canadabeeau Posted December 20, 2009 Author Share Posted December 20, 2009 yeah the images are like "image.jpg" and it display them but with their website around it, i stumbled on it while googling an image and clicked it and it came up with the page rather than the image and the page in a frame below, maybe someone here remembers the site name that does this Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980796 Share on other sites More sharing options...
teamatomic Posted December 20, 2009 Share Posted December 20, 2009 I'm a bit rusty with .htaccess but try something like this: RedirectMatch 301 (.*)\.(gif|jpg|jpeg|png)$ http://www.domain.com/redirect/$1.php What this should do is redirect something like: http://domain.com/images/picture1.gif to http://domain.com/redirect/picture1.php Now, you really dont need to make a file for every pic. All you need to do is have a custom 404 error page in php that busts out the file name and if its a graphic displays it in an included fragment of HTML. But like I said, I'm a bit rusty. Maybe someone more current could proof redirect. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980819 Share on other sites More sharing options...
keldorn Posted December 20, 2009 Share Posted December 20, 2009 You can use .htaccess and check for referrers. If the referrer is from Google images, then use mod_rewrite. You will need something in the image to identify it, like an ID in the image name. So you could have ID_randomString.jpg So say 3222_8due938d.jpg, using mod_rewrite you can grab the 3222 with regex, then point that to a php file like image.php?image_id=3222 Inside image.php you will have to 301 redirect them with ID to an album with the 3222 ID. Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980865 Share on other sites More sharing options...
dreamwest Posted December 20, 2009 Share Posted December 20, 2009 if you have an image url: http://site.com/img/pic.jpg Just parse the url and curl the site $img_url = "http://www.phpfreaks.com/media/images/forums/logo.png"; $url = parse_url($img_url); $u = "http://".$url['host']; $ch = curl_init($u); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $str = curl_exec($ch); curl_close($ch); if ($str === false) { echo "cURL failed "; die(); } echo "<img src='{$img_url}'><hr>This image found here!<hr>"; echo $str; Quote Link to comment https://forums.phpfreaks.com/topic/185748-images/#findComment-980867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.