When another site includes one of my images, like

<img border="0" src="" width="24" height="24">

, for example, in their own page, can I redirect it to another place?
I think is not possible, but it doesn't hurt to ask.

So far I can only redirect images on my site if someone tries to enter them in browser's address or to replace the image with another if they're included in another page, like above.

Dani AI

Generated

Short answer: no — you cannot make another site’s page navigate to your site simply by serving an image. When a browser fetches an image for an <img> tag it only requests that resource; returning HTML or a redirect will not cause the embedding page to load your site. That is why attempts to “redirect” embedded images won’t win you their visitors, and why ’s caution about hijacking is important.

A practical, standard response is to block or replace hotlinked images on your server. The usual server-side method checks the HTTP Referer header and either denies access or returns a placeholder image. As pointed toward, .htaccess (mod_rewrite) is commonly used; read up on the Referer header here: Referer header. Example approaches:

# deny hotlinked image requests (403)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?yourdomain\.com/ [NC]
RewriteRule \.(jpe?g|png|gif)$ - [F,NC]
# or send a placeholder image instead of the original
RewriteRule \.(jpe?g|png|gif)$ /images/no-hotlink.jpg [L,R=302,NC]

Notes and alternatives: Referer checks are imperfect (some browsers, proxies, and privacy tools strip or spoof Referer). For stronger control, serve images through a script that validates tokens/session or use expiring signed URLs from a CDN/S3. Watermarking and periodic filename rotation make unauthorized reuse less attractive. For persistent abuse, consider takedown requests rather than active “hijacking.”

Quick troubleshooting: test rules with curl by sending a fake Referer header to reproduce hotlink requests and check server response. Keep the user experience in mind — returning HTML to an image request will usually just show a broken image, not a redirected page.

Recommended Answers

All 5 Replies

this is a hot topic and there are tutorials

AltLab

has my favorite, easy to follow, flexible

this is a hot topic and there are tutorials

AltLab

has my favorite, easy to follow, flexible

This is exactly what I've said I know how to do :)
More clear: I want the included picture to redirect to a page, not to another picture, therefore redirecting the page that includes it... if possible, 'cause I haven't found it in any tutorial so far

sorry, out of brain space,
redirect to a html page instead of an image ??
not sure it can be done either
it should be cause you can make <img src='filename'php'> for generated images
how about a html file with a breakout script that loads your page

Our image protect looks like this and has the site address

My impresion is that it's not possible, also... I was hoping somehow to gain something (like their visitors) from all the sites that curently have my images embeded :) Like a revenge of some kin

That is the equivalent of hijacking a website. and is a security violation. It might be illegal.

How do other sites have your images embedded in such a way that you can access them?

Are they doing a link to your image on your site. If so, you can change the url of your picture and the associated link every so often, and put a different image in for the old picture url.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.