admin管理员组文章数量:1418072
When a user type inn www.mypage/x (which does not exist) the result show an empty body with the header and the footer intact. Most redirect plugins let me redirect one specific URL to another specific URL. What i want is to not only redirect a specific URL, but every non existing URL to a specific URL.
What does this redirecting action called, and how to i do that?
When a user type inn www.mypage/x (which does not exist) the result show an empty body with the header and the footer intact. Most redirect plugins let me redirect one specific URL to another specific URL. What i want is to not only redirect a specific URL, but every non existing URL to a specific URL.
What does this redirecting action called, and how to i do that?
Share Improve this question asked Jul 30, 2019 at 22:45 jan henriksenjan henriksen 11 bronze badge 1- Do you mean redirect on 404 not found? – Tom J Nowell ♦ Commented Jul 31, 2019 at 1:14
1 Answer
Reset to default 2You can use conditional tag is_404()
and wp
action hook to redirect whenever the page can not be found.
functions.php
add_action( 'wp', 'se344018_redirect_404' );
function se344018_redirect_404()
{
if ( is_404() ) {
wp_redirect( home_url() );
//
// wp_redirect( home_url('some/page-slug') );
exit;
}
}
本文标签: urlsRedirect non existing page to frontpage
版权声明:本文标题:urls - Redirect non existing page to frontpage 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745281975a2651474.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论