Last active
May 10, 2023 14:42
-
-
Save chrisns/52f9fbb576128598668900917868f234 to your computer and use it in GitHub Desktop.
flip between internet explorer mode and edge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# site needs to be in the configurable list | |
# follow this guide: https://learn.microsoft.com/en-us/deployedge/edge-learnmore-configurable-sites-ie-mode | |
http { | |
server { | |
set $ieaction ''; | |
if ( $http_x_internetexplorermodeconfigurable = 1) { | |
set $ieaction "configurable+${ieaction}"; | |
} | |
if ($http_x_internetexplorermodeconfigurable != 1) { | |
set $ieaction "nonconfigurable+${ieaction}"; | |
} | |
if ( $http_user_agent ~* Trident ) { | |
set $ieaction "ie+${ieaction}"; | |
} | |
if ( $http_user_agent !~* Trident ) { | |
set $ieaction "nonie+${ieaction}"; | |
} | |
# if IE mode desired: | |
location /iemode { | |
if ( $ieaction = 'nonie+nonconfigurable+') { | |
return 402 'requires Internet Explorer mode'; | |
} | |
if ( $ieaction = 'nonie+configurable+') { | |
add_header X-InternetExplorerMode 1; | |
return 302 $request_uri; | |
} | |
} | |
# if Edge mode desired: | |
location /edgemode { | |
if ( $ieaction = 'ie+nonconfigurable+') { | |
return 402 'requires non-internet explorer mode'; | |
} | |
if ( $ieaction = 'ie+configurable+') { | |
add_header X-InternetExplorerMode 0; | |
return 302 $request_uri; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment