Forum Moderators: phranque

Message Too Old, No Replies

Delivering a different image file based on User Agent

Help Meh!

         

Teknorat

4:31 am on Jan 7, 2005 (gmt 0)

10+ Year Member



Hi all, I've been trying to come up with a way whereby I can have someone end up with a different image depending on their user agent. So far I've come up with this which I placed in the folder where the image is stored:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^MSIE [NC]
RewriteRule ^.*$ [mysite.com...] [L]

which does absolutely nothing. Can anyone help me out here? I'll love you forever if you can! :P

Marino

10:08 am on Jan 7, 2005 (gmt 0)

10+ Year Member



Hello,

Is the mod_rewrite enabled on your server?

Your regular expression will match any user_agent string that begins with "MSIE" (begins with, and not contains). Is that what you want?

Span

10:57 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the image is on a page, you could use SSI:

<!--#set var="agent" value="$HTTP_USER_AGENT" -->
<!--#if expr="$agent = /MSIE/" -->
<img src="" width="" height="" alt="" title="" />
<!--#elif expr="$agent= /Firefox/" -->
<img src="" width="" height="" alt="" title="" />
<!--#elif expr="$agent= /Netscape/" -->
<img src="" width="" height="" alt="" title="" />
<!--#elif expr="$agent= /Safari/" -->
<img src="" width="" height="" alt="" title="" />
<!--#else -->
<img src="" width="" height="" alt="" title="" />
<!--#endif -->

[edited by: Span at 11:56 am (utc) on Jan. 7, 2005]

Marino

11:46 am on Jan 7, 2005 (gmt 0)

10+ Year Member



Try to remove the "^" in your regexp. Should work find as long as you mod_rewrite is enabled.

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} MSIE [NC]
RewriteRule ^.*$ [mysite.com...] [L]

Teknorat

1:06 pm on Jan 7, 2005 (gmt 0)

10+ Year Member



Haha it's alive it's alive! Thank you all a tonne :D