Whatever your reason, if you'd like to bar Microsoft's Internet Explorer browsers from your site, here's how you can accomplish it. Note that this could be easily made to work with (or rather, against) any other browser you chose, or against service providers, operating systems, IP addresses containing the number '7,' etc.
The ethics of the situation, and the decision, are rather complicated. My own justification is that I'm angered by the degree to which Microsoft has abused, exploited and tried to control the Internet, and if people are going to come to my proverbial electronic front door with that browser, I'm going to make them click through me griping about it first. Users of the web might have a reasonable expectation of impartial, gracefully-degraded service, but not all that plus freedom from other people's grousing.
This approach assumes you have the ability to put CGIs on your site, and have the filenames properly MIME-parsed for display or execution. If your ISP or server environment doesn't provide that, there are a couple other things you can try.
#!/usr/bin/perl -Tw if ($ENV{'HTTP_USER_AGENT'} && $ENV{'HTTP_USER_AGENT'} =~ /MSIE|Internet Explorer/i) { print "Location: http://www.domain.com/ie_reject.shtml\n\n"; } else { print "Location: http://www.domain.com/piano.shtml\n\n"; } exit;
<meta http-equiv="refresh" content="0; url=http://www.domain.net/cgi-bin/index.cgi">Then take the code for index.cgi above and put that in /cgi-bin/index.cgi.
<meta http-requiv="refresh" content="0; url="<!--#include cmd="index.cgi"-->">
<?php if (eregi("MSIE",getenv("HTTP_USER_AGENT")) || eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) { Header("Location: http://www.domain.com/ie_reject.html"); exit; } ?>
Update: this is known to work with PHP3 and beta versions of PHP4.
This was contributed by Eric Sechrist <newwave/atnewwave.primeline.\moc>. Haven't tried it myself, but the product page for it indicates that Miva is a server-side scripting language with a respectable supported platforms list.
Place this code at the top of your index.mv file, and adjust 'reject.txt' to whatever file you prefer (presumably including HTML):
<MvIF EXPR = "{ 'msie' CIN http_user_agent }"> <MvDO FILE = "reject.txt"> <MvEXIT> </MvIF>
This approach works with Macromedia's ColdFusion server-side application environment (formerly from Allaire). Contributed by Justin Felker.
<CFIF findNoCase("msie", cgi.http_user_agent)> <CFLOCATION url="ie_reject.html" addtoken="no"> <CFELSE> <CFLOCATION url="real_page.html" addtoken="no"> </CFIF>
Also from Justin Felker: this approach works with Sun's Java Server Pages (JSP).
<% if (request.getHeader("User-Agent").toLowerCase().indexOf("msie") != -1) response.sendRedirect("ie_reject.html"); else response.sendRedirect("real_page.html"); %>
This approach employs the flow control element capability in the wonderful Apache webserver, v1.2 and later. As of this writing, more than half the webservers on the net run Apache, including a large percentage of ISPs and hosting agencies. To find out if you can use this method, telnet to port 80 of the webserver and enter "HEAD / HTTP/1.0", then press enter twice; look through the resulting headers for the "Server:" header, which should contain the server name and version. Microsoft's IIS webserver may support some feature like this also, but chances are if you're running IIS you aren't likely to employ this whole procedure anyway. Documentation on Apache's mod_include SSI module can be found here.
As above, move your "real" entry page to another file (realhomepage.html assumed here), create your IE rejection file (reject.html assumed). You'll generally need to create your index file as index.shtml instead of .html; this may vary between webservers. Be sure that index.shtml is the only "index" file present, as many webservers will prefer .html and/or .htm files over .shtml in the selection order.
<!--#if expr="$HTTP_USER_AGENT = /MSIE/" --> <!--#include virtual="reject.html" --> <!--#elif expr="$HTTP_USER_AGENT = /Internet Explorer/" --> <!--#include virtual="reject.html" --> <!--#else --> <!--#include virtual="realhomepage.html" --> <!--#endif -->
This approach has the advantage of working on a large portion of webservers; however, it does not prevent loading the "real" page via MSIE via some other path (search engine referral, etc).
This is a good fallback if you aren't able to use any server-executed code. It has the benefit of being fairly difficult to defeat, since it works on the browser's appName property, which is usually hardcoded into the browser and is difficult to change. The disadvantages are that, first, it will annoy users of browsers that don't use javascript; second, it will permit entry by MSIE users when they have JavaScript disabled. The <meta> redirect will attempt to cope with browsers that don't support or aren't configured to use JS.
<html> <head> <meta http-equiv="refresh" content="1; URL=http://www.domain.com/realhomepage.html"> </head> <body> <script language="javascript"> <!-- if (navigator.appName == "Microsoft Internet Explorer") { document.location = "http://www.domain.com/ie_reject.shtml"; } else { document.location = "http://www.domain.com/realhomepage.html"; } // --> </script> </body> </html>