我在Wordpress中有两个帖子:
post_title: gröband
permalink: www.example.com/groband.html
post_title: groband
permalink: www.example.com/groband-2.html
我希望在搜索查询为" gröband
"时重定向到www.example.com/groband.html
如果搜索查询为" groband
"重定向到www.example.com/groband-2.html
答案 0 :(得分:1)
在主题编辑器中编辑搜索模板并添加此顶部
<?php
if(isset($_GET['s'])){
$url ="";
switch($_GET['s']){
case 'gröband':
$url = "http://www.example.com/groband.html";
break;
case 'groband':
$url = "www.example.com/groband-2.html";
break;
}
if(!empty($url)){
header("Location: ".$url);
}
}
?>
或
<?php
if(isset($_GET['s'])){
switch($_GET['s']){
case 'gröband':
header("Location:http://www.example.com/groband.html");
break;
case 'groband':
header("Location:http://www.example.com/groband-2.html");
break;
}
}
?>