Forum Moderators: DixonJones

Message Too Old, No Replies

is there a way to force browser redirect as a reply to <IMG src=.cgi>

is there a way to force browser redirect as a reply to <IMG src=.cgi>

         

martin_k

11:46 am on Jan 23, 2003 (gmt 0)

10+ Year Member



I have had to cancel some accounts of my free counter service. But some of them do not remove the code: <IMG src=http://www.my-site.com/cgi-bin/counter.cgi width=1 height=1>

Is it possible to redirect the browser to a different URI (e.g. with HTTP headers) when sending back the IMG to the browser.

I have tried several methods. No success.

(Or maybe you have some other idea how to force such forgetful webmasters to remove the code from their pages if they do not read their e-mails.)

bcc1234

11:48 am on Jan 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are using apache - check out the proxy module. That might be of use.

martin_k

12:30 pm on Jan 23, 2003 (gmt 0)

10+ Year Member



If I understand right the ProxyPassReverse directive or ProxyPass directive will just redirect response to the client from [mysite.com...] to www.somewhere-else.com.

The problem here is that the browser will not be redirected to a different site/page. Only the <IMG> will be served from www.somewhere-else.com.

Please correct me if I have misunderstood something.

jdMorgan

5:11 pm on Jan 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



martin_k,

If you can identify the requesting page by referrer, you can use an internal redirect to return a 1x1 transparent GIF in place of the counter, or perhaps a replacement GIF with the word "Cancelled" in it.

Something like this:


RewriteCond %{HTTP_REFERER} ^http://www\.lazysite\.com [NC]
RewriteRule ^/cgi-bin/counter\.cgi /some_image_dir/transparent1x1.gif [L]

The above assumes mod_rewrite code in httpd.conf. If using mod_rewrite in .htaccess, remove the first slash following "RewriteRule ^". If you really wish to redirect the browser for some reason, change the flag at the end of the above RewriteRule to [R=301,L]

More info: Introduction to mod_rewrite [webmasterworld.com]

HTH,
Jim

martin_k

7:11 pm on Jan 23, 2003 (gmt 0)

10+ Year Member



jdMorgan,

Thanks. To return an image with the word "Cancelled" in it would be a good idea. But it does not work in my case. As you could see from my <IMG... code in my original post, it actually is the 1x1 GIF that I am returning to the IMG request. (It is only for the counting -- the counter is displayed with the help of another code)
If I would not have the WIDTH=1 and HEIGHT=1 specified in the IMG tag then I could return an image with the word "Cancelled" in it.
But as far as I know it is not possible to force the browser to ignore the WIDTH and HEIGHT specified in the IMG tag.

So, there could be at least two ways how to solve the problem:
FIRST: To redirect the client to another page (as a reminder for the forgetful webmaster)
SECOND: To return an image with the word "Cancelled" in it. But then I should try to force the browser to ignore the WIDTH and HEIGHT of the IMG tag.

If you have any ideas, please help me with this!

.

jdMorgan

8:11 pm on Jan 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



martin_k,

Well, I experimented with this for awhile, and what I find is that you have no good choices:

You can redirect to another image, but since the img attributes are 1x1, no-one will see it.
You can return a 403-forbidden code.

About the only thing I can think of is to do this:

RewriteCond %{HTTP_REFERER} ^(http://www.lazywebmaster1\.com) [NC,OR]
RewriteCond %{HTTP_REFERER} ^(http://www.lazywebmaster2\.com) [NC,OR]
RewriteCond %{HTTP_REFERER} ^(http://www.lazywebmaster3\.com) [NC]
RewriteRule ^/cgi-bin/counter\.cgi %1/please_remove_MartinK_counter_from_your_site.gif [R=301,L]

This will result in a request back to the cancelled-member-site for a gif image which does not exist. This will cause 404 errors in that site's error log until the counter image link is removed. However, there is still no guarantee that the webmaster will notice these errors.

HTH,
Jim

Eric_Winter

4:04 am on Jan 24, 2003 (gmt 0)

10+ Year Member



Hmm . . . .

I presume you need to keep that code intact for existing users, so these solutions would require you to be able to identify the caller, i.e. calling page, you won't get this 100% of the time, but you'll get it 95% of the time.

Presuming that that's acceptable:

How about sending a HUGE image in terms of file size. The page would take forever to load. That might get noticed.
. . . Not very nice though.

Not nearly as in-your-face option
I'f the requested file currently has a compact P3P policy, you could take it out. That would throw a little privacy error for some browsers . . . not very likely to cause most webmasters any headaches . . . or to be noticed I suppose.

martin_k

6:15 am on Jan 24, 2003 (gmt 0)

10+ Year Member



jdMorgan, Eric_Winter,

Those were very good suggestions.
I think I will use both of them: (1) redirect the request for the image back to [lazywebmaster3\.com...] and (2) send a special P3P header with HTTP.

Probably there is not much more to be said about it and I guess the issue is closed.