您永远不能信任用户输入。始终准备要在自己的代码中使用的值。示例:
$path = filter_input( INPUT_SERVER, \'REQUEST_URI\', FILTER_SANITIZE_URL );
if ( $path )
{
$url = \'http://old.example.com\' . $path;
$url_escaped = esc_url( $url );
$status = 301;
$message = "Moved to <a href=\'$url_escaped\'>$url_escaped</a>.";
wp_redirect( \'http://old.example.com\'. $path, $status );
wp_die( $message, \'Moved\', $status );
}