Jump to content



Recommended Posts

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:





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.







Link to comment
Share on other sites

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.

Link to comment
Share on other sites

if you have an image url:




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: Gecko/2009042316 Firefox/3.0.10');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$str = curl_exec($ch);

if ($str === false) {
echo "cURL failed  ";

echo "<img src='{$img_url}'><hr>This image found here!<hr>";
echo $str;


Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.