Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent IE from viewing my website?

I'd like to take elitism to the n-th degree by not allowing Internet Explorer to browse my website.

Is there a way to do such a thing? My website is built upon the CakePHP framework, if that helps.

like image 933
tigertrussell Avatar asked Dec 21 '22 03:12

tigertrussell


2 Answers

I'm pretty sure all IE versions support the following - does require JavaScript though.

<!--[if IE]>
<script type="text/javascript">
window.location = "http://www.google.co.uk/chrome"
</script>
<![endif]-->
like image 97
472084 Avatar answered Jan 12 '23 00:01

472084


If you want to do it in PHP, you can use the $_SERVER['HTTP_USER_AGENT'] variable to read in the user agent and then look to see if it's using IE, and stop loading if so. You'd want to use a regex on the string, with a simple example being:

if (preg_match("Internet Explorer", $_SERVER['HTTP_USER_AGENT']) == 0) {
    // print message or whatever and abort
}
like image 39
Dan Fego Avatar answered Jan 12 '23 01:01

Dan Fego