我希望基于浏览器进行重定向,但只针对特定页面(或2)。如果浏览器为IE7或更低版本,我想将用户发送到另一个页面。alt页面将有完全不同的设置,所有内容都适用于他们的旧垃圾。
我找不到插件。我正在考虑做一个php注入插件,使这个页面特定。
有什么建议吗?
我希望基于浏览器进行重定向,但只针对特定页面(或2)。如果浏览器为IE7或更低版本,我想将用户发送到另一个页面。alt页面将有完全不同的设置,所有内容都适用于他们的旧垃圾。
我找不到插件。我正在考虑做一个php注入插件,使这个页面特定。
有什么建议吗?
如果您只想检测特定于IE的浏览器,那么下面的代码可以帮助您。您需要用重定向代码替换注释
function browser_detection_redirect(){
preg_match(\'/MSIE (.*?);/\', $_SERVER[\'HTTP_USER_AGENT\'], $matches);
if (count($matches)>1){
//Then we\'re using IE
$version = $matches[1];
switch(true){
case ($version<=8):
//IE 8 or under!
break;
case ($version==9):
//IE9!
break;
default:
//You get the idea
}
}
}
您必须调用上的函数WordPress init hook 要重定向:add_action(\'init\', \'browser_detection_redirect\');
要在特定页面上添加此代码,需要使用is_page WordPress function.这个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;
}
}
我有一些预定义的链接,需要重定向到WP安装中的真实URL。不幸的是,我别无选择,只能使用提供给我的这些URL。格式为:http://mysite.com/redirect.html?p=pagenameWP安装在mysite的根目录下。com。我需要获取pagename查询变量,它不会与页面URL直接匹配,并将其重定向(301)到WP permalink。我尝试了几件事。htaccess具有重写功能,但运气不佳,这主要是因为还有WP permalinks重定向。有人以前做过这件事,或者知道最好的方法吗?更
我希望基于浏览器进行重定向,但只针对特定页面(或2)。如果浏览器为IE7或更低版本,我想将用户发送到另一个页面。alt页面将有完全不同的设置,所有内容都适用于他们的旧垃圾。
我找不到插件。我正在考虑做一个php注入插件,使这个页面特定。
有什么建议吗?
如果您只想检测特定于IE的浏览器,那么下面的代码可以帮助您。您需要用重定向代码替换注释
function browser_detection_redirect(){
preg_match(\'/MSIE (.*?);/\', $_SERVER[\'HTTP_USER_AGENT\'], $matches);
if (count($matches)>1){
//Then we\'re using IE
$version = $matches[1];
switch(true){
case ($version<=8):
//IE 8 or under!
break;
case ($version==9):
//IE9!
break;
default:
//You get the idea
}
}
}
您必须调用上的函数WordPress init hook 要重定向:add_action(\'init\', \'browser_detection_redirect\');
要在特定页面上添加此代码,需要使用is_page WordPress function.这个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;
}
}
请帮助我克服重定向问题。我需要在子域上工作,而不是在主域上工作,但这里两个域是不同的。我所做的是-将所有(website.com)文件复制到另一个子域(demo.websiteA.com),并根据wp配置更改数据库名称。php文件。但每当我尝试打开演示时。网站a。com它重定向到网站。com公司请帮帮我提前感谢