Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
重定向所有带有查询字符串的Wordpress页面,搜索页面除外_Wordpress_.htaccess_Redirect_Seo_Permalinks - Fatal编程技术网

重定向所有带有查询字符串的Wordpress页面,搜索页面除外

重定向所有带有查询字符串的Wordpress页面,搜索页面除外,wordpress,.htaccess,redirect,seo,permalinks,Wordpress,.htaccess,Redirect,Seo,Permalinks,我以前的Wordpress博客没有使用漂亮的永久链接,而是使用难看的查询字符串来确定页面/文章。我已将我的博客从“blog.domain.com”移动到“newblog.domain.com”,并尝试将所有带有难看查询字符串的旧页面URL重定向到我的新博客主页。我想对除Wordpress搜索查询之外的所有查询字符串执行此操作?s= 如何将除搜索查询之外的所有查询字符串重定向到我的新博客主页 我知道如何重定向所有查询字符串,但如何仅排除搜索查询?如果主题中有一个404.php模板,在get_hea

我以前的Wordpress博客没有使用漂亮的永久链接,而是使用难看的查询字符串来确定页面/文章。我已将我的博客从“blog.domain.com”移动到“newblog.domain.com”,并尝试将所有带有难看查询字符串的旧页面URL重定向到我的新博客主页。我想对除Wordpress搜索查询之外的所有查询字符串执行此操作
?s=

如何将除搜索查询之外的所有查询字符串重定向到我的新博客主页


我知道如何重定向所有查询字符串,但如何仅排除搜索查询?

如果主题中有一个404.php模板,在get_header()上方,请检查是否正在使用$\u get变量's'

if(isset($_GET['s'])) {

    //DON'T do redirect

} else {

    //redirect now
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: " . $new_url);

}

我更愿意使用301重定向进行SEO编辑——您可以在php中执行301重定向。如何获取$new_url变量取决于您,但是您可以根据url的id使用get_permalink()函数