FAQ

Page Discussion History

LimitBrowsers

Revision as of 06:43, 23 November 2010 by MichaelLustfield (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The following explains how to limit browser support to only recent versions of Chrome, Firefox, Internet Explorer and Safari (+ Mobile Safari and Palm Pre).

##
# Supported browsers
##
 
modern_browser gecko 1.9;
 
# note that Safari related directives match
# Chrome, Mobile Safari, Palm Pre and other WebKit-based browsers here, too, thanks
# to all of them using almost identical User-Agent strings
modern_browser safari 3.0;
modern_browser safari 3.1;
modern_browser safari 3.2;
modern_browser safari 4.0;
 
modern_browser msie 7.0;
modern_browser msie 8.0;
 
modern_browser unlisted;
 
##
# Non-supported browsers
##
 
ancient_browser msie 4.0;
ancient_browser msie 5.0;
ancient_browser msie 5.5;
ancient_browser msie 6.0;
 
# Here is how one can disable support of a specific browser
ancient_browser opera 7;
ancient_browser opera 8;
ancient_browser opera 9;
ancient_browser opera 10;
 
ancient_browser konqueror 3;
ancient_browser konqueror 4;
 
ancient_browser Links Lynx Netscape4;
 
#
# Now, to the fun part. If we perform a rewrite on every
# request here, images won't be displayed, so we have to
# do some extra work besides just
#
# if ($ancient_browser){
# rewrite ^ /unsupported_browser.html;
# break;
# }
 
set $unsupported_browser_rewrite do_not_perform;
 
if ($ancient_browser){
  set $unsupported_browser_rewrite perform;
}
 
if ($uri !~* /\.(jpeg|jpg|png|ico|gif|js|css)$/) {
  set $unsupported_browser_rewrite do_not_perform;
}
 
if ($unsupported_browser_rewrite = perform){
  rewrite ^ /unsupported_browser.html;
  break;
}