What function can be used to redirect users based on different domain inputs in PHP?

To redirect users based on different domain inputs in PHP, you can use the $_SERVER['HTTP_HOST'] variable to get the current domain the user is accessing. You can then use conditional statements to check the domain and redirect the user accordingly.

$current_domain = $_SERVER['HTTP_HOST'];

if($current_domain == "example1.com"){
    header("Location: https://www.example1.com");
    exit();
} elseif($current_domain == "example2.com"){
    header("Location: https://www.example2.com");
    exit();
} else {
    header("Location: https://www.defaultdomain.com");
    exit();
}