admin管理员组文章数量:1334704
I am using the following code to change the url of my search results page:
function wpb_change_search_url() {
if (is_search() && !empty($_GET['s'])) {
wp_redirect(home_url("/suche/") . urlencode( get_query_var('s')), 301);
exit();
}
}
add_action('template_redirect', 'wpb_change_search_url');
It works perfectly. Now I want to redirect an empty search as well. Right now an empty search leads to /?s=
but it should redirect to /suche
. I managed to do the redirect but the browser shows a 404 for /suche
.
I have tried every possible thing I could find online but nothing worked. Hopefully someone has an idea. Any help would be greatly appreciated!
My permalinks structure is /%postname%
if that might be of importance.
本文标签: url rewritingRedirect empty search to another page
版权声明:本文标题:url rewriting - Redirect empty search to another page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742358936a2459972.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论