Redirecting IE users
Posted by Alex | Posted in Coding Secrets | Posted on 05-11-2009
1
So, as you may know I have been launching a new site lately called The Mac Coach. This site was designed to help new mac users get going with their macs and help older users gain a deeper understanding of the software they already use. It officially launched a few days ago, and I was really excited. Well something I quickly noticed was that my site doesn’t seem to be compatible with Internet Explorer. In most cases this would be a bummer, as IE holds a large majority of browser usage demographics. However since my site was pretty much designed with Mac users 100% in mind, the IE market is rather miniscule.
Since IE was butchering the design of my beautiful website, I decided to simply add some code so that when an IE users logs onto The Mac Coach, they will be redirected to another page that informs them of incompatibilities and recommends that they install another browser. I feel that I can handle my own when it comes to HTML and coding, when i get the proper help. So I scoured the web for some hints. Unfortunately all that i found were some hit or miss sites that only partially explained it. My purpose today is to pass the knowledge that I gained onto my readers, so that it will be easier for the next guy to do this.
There are multiple ways to do this. I found many. However I will explain to you the easiest that I discovered. It is one line of code that you throw in the <meta> tags.
First of all, you need to quickly design a page to redirect these Internet Explorer users to. I threw a simple one together in about 5 minutes. I didn’t worry about fancy colors or any of that. I made the page as simple as possible to ensure that it was IE compatible. You can view my redirect page here: http://www.themaccoach.com/ie.html
In fact, I give anyone that is reading this, permission to use the redirect page that I created for FREE, no strings attached. (right-click and “save linked file as…” to save the HTML file and load it onto your own server) or (just link to that exact web address on my site). In return for using my file, you can just tell more people about my blog, The Mac Coach, or subscribe to either.
Now it is time to insert the code. Add this line of code to your <meta> tags . If you already have meta tags, then add it as the first meta tag, on its own line.
<!–[if ie]><meta http-equiv=”refresh” content=”0;URL=http://www.themaccoach.com/ie.html”><![endif]–>
This is a conditional statement that only IE will read. To all other browsers it will look like a comment and get ignored. So it does absolutely nothing to your site if they are not IE users. Plus, it is only one line of simple code and it won’t affect load times since it acts as a simple comment.
To customize this statement you can (probably should) change the web address to your own redirect page. Also where you see the “0″ before the “URL” you can change that to the time in seconds that you want to wait before you redirect. With 0 set, it will happen near-instantly. However, there is some delay still.
So that is all there is to it! Now there are other ways to do this same thing that you might know. If you would like to share, you can post it as a comment below. Also, let me know if you use this and it works for you.


Nice find, I was not aware of that conditional meta statement.