This script may not be for everyone but it is pretty cool.
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua,'MSIE') != false && strpos($ua,'Opera') === false)
{
if (strpos($ua,'Windows NT 5.2') != false)
{
if(strpos($ua,'.NET CLR') === false) return;
}
if (substr($ua,strpos($ua,'MSIE')+5,1) < 7)
{
header('Location: http://redirect.com');
}
}
?>
That little snippet of PHP coding will redirect all IE6 users to a different page. This is perfect for designers who want the follow the trend of Open Addict and block all IE users from viewing their website. You can find out more about this code here. Also do not forget the opening and closing tags.
21 Comments
September 11, 2007 at 7:36 am
This is great! I am not a fan of IE7…
I use Vista, XP and the Mac OS (yes, I have the OSX installed on my PC) and obviously test everything I do with Vista+IE7, Vista+Firefox, Vista+Safari, XP+IE6, XP+Firefox, XP+Opera, OSX+Safari, OSX+Firefox and it’s only IE7 that screws everything up…
September 11, 2007 at 5:20 pm
OSX on PC?
IE7 works fine for me, it is just IE6.
September 12, 2007 at 9:31 am
Yeah. As OSX is essentially a modified Linux, it’s a case of modifying it back again. Now that Mac uses Intel processors it’s also really easy to do.
I first of all tested whether it’d work by setting it up on a Virtual Machine using this guide:
http://asendure.wordpress.com/2006/10/01/osx86-how-to-install-mac-os-x-on-vmware-server-amd-64/
(except I use the Intel drivers not the AMD drivers)
…then once I knew I had hardware that supported it virtually, I just had to make myself a Journal formatted FAT32 partition and use Acronis Disk Director’s OS selector to select between the OS’s when I boot up. Works great.
You can get modified drivers (usually modified Linux drivers) in the forums of this site:
http://www.insanelymac.com/
*
I never really had any design issues with IE6, but IE7 seems to display things differently… I guess that’s just another bad thing about IE! Everyone has different issues – but we ALL have issues! :)
September 12, 2007 at 8:36 pm
Wow, that is really cool. I might try it.
I think everyone hates IE6, even Microsoft.
October 6, 2007 at 9:13 am
Thank you for sharing!
October 6, 2007 at 12:28 pm
That’s nonsense. Just don’t care if your site works with IE and maybe tell them it’s their browser’s fault.
October 11, 2007 at 5:01 pm
Are you saying to just leave your site broken?
October 16, 2007 at 6:28 am
Sorry to respond OT again, but here’s a guide I used for a native install of OS X:
http://dilnalomo.googlepages.com/
October 16, 2007 at 5:31 pm
Thanks
October 20, 2007 at 11:58 pm
I need to just point out that you code has some mistakes. There is an extra } on line 6. Also when you copy and paste this code you need to be careful your using the right ‘ because the ones copied from the page are wrong.
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua,’MSIE’) != false && strpos($ua,’Opera’) === false)
{
if (strpos($ua,’Windows NT 5.2′) != false)
{ if(strpos($ua,’.NET CLR’) === false) return; }
if (substr($ua,strpos($ua,’MSIE’)+5,1) < 7)
{
header(‘Location: http://redirect.com‘);
}
}
October 21, 2007 at 5:39 pm
Thank you very much for pointing that out.
WordPress was giving me some errors when I tried to input the code.
Thanks
December 10, 2007 at 6:41 pm
Sorry guys.
August 15, 2008 at 5:39 am
Thanks
September 10, 2008 at 7:02 am
What does this section do?
if (strpos($ua,’Windows NT 5.2′) != false)
{ if(strpos($ua,’.NET CLR’) === false) return; }
Don’t you just need to check if the $ua string returns ‘MSIE 6.0′ ?
September 10, 2008 at 10:07 pm
-http://lab.amanwithapencil.com/user_agent/
November 1, 2008 at 3:12 pm
Thank you for this code! After 10 hours of trying every Internet Explorer 6 png hack that I could find, iepngfix.htc, and receiving less than satisfactory results in my WordPress site – this was the absolute best solution.
The corrected redirect is PERFECT.
March 20, 2009 at 11:37 am
..And remember to redirect to http://www.crashie.com
May 12, 2009 at 3:11 pm
[...] More about the code above Here. [...]
July 14, 2009 at 9:25 pm
Very fast and perfect redirect script. Thanks a LOT.
October 29, 2009 at 2:20 am
I was wondering… How do i get this to work… do I paste it into the body? or header nothing seems to work
November 2, 2009 at 6:30 pm
I agree with test.
I paste this in at the very top of the code:
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
if (strpos($ua,’MSIE’) != false && strpos($ua,’Opera’) === false)
{
if (strpos($ua,’Windows NT 5.2′) != false)
{ if(strpos($ua,’.NET CLR’) === false) return; }
if (substr($ua,strpos($ua,’MSIE’)+5,1)
Messgae I get is:
I get a parse error Unexpected T_STRING in mywebsite.com on line 6