您可以在这里过滤重定向,我认为这对您有用
add_filter( 'allowed_redirect_hosts' , 'my_allowed_redirect_hosts' , 10 );
function my_allowed_redirect_hosts($content){
$content[] = 'blog.example.com';
$content[] = 'codex.example.com';
// wrong: $content[] = 'http://codex.example.com';
return $content;
}
有关此处的更多信息https://codex.wordpress.org/Function_Reference/wp_safe_redirect
在您的文本编辑器中复制以下代码更改示例主机域并将其保存为 allowed-host-plugin.php 放入名为 allowed-host-plugin 的文件夹中并将其上传到您的插件目录 转到您在管理员中的插件并激活. 那是它应该工作的。
<?php
/*
Plugin Name: Allowed Host Plugin
Description: Site specific code changes for allowed host domains no admin change in code below
*/
/* Start Adding Functions Below this Line */
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
add_filter( 'allowed_redirect_hosts' , 'my_allowed_redirect_hosts' , 10 );
function my_allowed_redirect_hosts($content){
// Add your allowed hosts below
$content[] = 'blog.example.com';
$content[] = 'codex.example.com';
// wrong: $content[] = 'http://codex.example.com';
return $content;
}
/* Stop Adding Functions Below this Line */
?>