<?php // Put in this array every substring that identifies the URL of an image search: $hr = array("images.google", "images.search.yahoo.com", "search.live.com/images/"); // Assign the requested URL to $imgpath (you may want to add some extra input security check here) $imgpath = $_GET["imgpath"]; // Loop the array foreach($hr as $imgreferrer) { $found = strpos($_SERVER["HTTP_REFERER"], $imgreferrer); // Check the actual referer against the given ones if ($found !== false) { // if an Image Search URL is detected in the HTTP REFERER value, show your landing page: header("Content-type: text/html"); ?> <!-- put here the HTML code of your landing page (or place here a redirect to the landing itself): --> <h1>Image embed code: [HTML with image and backlink code follows]</h1> <img src="<?php echo $imgpath; ?>" alt="" /> <?php die(); // Don't go further in the Loop } } // Else, continue to serve the image regularly: header("Content-type: image/jpeg"); // MAKE SURE that the content type matches your image's one here echo file_get_contents($imgpath); // MAKE SURE you can open URLs in PHP with file_get_contents() ?>