Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.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重定向301上重定向断页404不工作_Wordpress - Fatal编程技术网

在wordpress重定向301上重定向断页404不工作

在wordpress重定向301上重定向断页404不工作,wordpress,Wordpress,如何在不使用插件的情况下将出现404错误的断页重定向到wordpress的主页 这就是我到目前为止所做的: Redirect 301 /404.php http://www.businessbid.ae/resource-centre/home/ 您所要做的就是打开主题文件夹中的404.php文件。如果它不存在,那么创建一个空白的php文件。将以下代码粘贴到其中: <?php header("HTTP/1.1 301 Moved Permanently"); header("Locati

如何在不使用插件的情况下将出现404错误的断页重定向到wordpress的主页

这就是我到目前为止所做的:

Redirect 301 /404.php http://www.businessbid.ae/resource-centre/home/

您所要做的就是打开主题文件夹中的404.php文件。如果它不存在,那么创建一个空白的php文件。将以下代码粘贴到其中:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>

在调用
get\u header()


window.location.assign(“”)

这应该是使用WordPress(add to functions.php)解决问题的最佳方法:


我已经在我的本地电脑上测试过了,而且还在工作。再查一遍。你把这个代码放在活动主题上了吗?在正确的404文件中。?
<script>
  window.location.assign("<?php bloginfo('url')?>")
</script>
<?php exit; ?>
add_action('template_redirect','chk_404_redirect');

function chk_404_redirect() {
   if(is_404()) {
      wp_redirect( home_url() ); exit;
   }
}