这个phpbrowscap 课堂看起来非常适合你要做的事情。首先,您需要从github下载源代码并上传Browscap。php文件,然后使用以下php检查正在使用的IE版本,并根据版本重定向到不同的URL:
// Loads the class
require \'Browscap.php\';
// The Browscap class is in the phpbrowscap namespace, so import it
use phpbrowscap\\Browscap;
// Create a new Browscap object (loads or creates the cache)
$bc = new Browscap(\'cache\');
// Get information about the current browser\'s user agent
$current_browser = $bc->getBrowser();
//only do something if browser is IE
if($current_browser->Browser == "IE") {
// print the resulting stdClass object, remove this in final code!
echo \'<pre>\'; // some formatting issues ;)
print_r($current_browser);
echo \'</pre>\';
switch($current_browser->MajorVer){
case ("11"):
echo "Browser is IE 11!";
break;
case("10"):
echo "Browser is IE 10!";
break;
case("9"):
echo "Browser is IE 9!";
break;
case("8"):
echo "Browser is IE 8!";
$url = home_url() . "/ie8page";
wp_redirect($url);
exit(); // this is required after wp_redirect per the codex!
break;
case("7"):
echo "Browser is IE 7!";
//$url = home_url() . "/ie7page";
//wp_redirect($url);
//exit(); // this is required after wp_redirect per the codex!
break;
}
}