Search code examples
http-redirecthostnamecloaking

Redirect User based on hostname


The idea is to redirect the user group A with "aaa" in their hostname to url.com/a/ and send user group B with "bbb" in their hostname to url.com/b/

Would appreciate any hint!


Solution

  • <?php
    $path = $_SERVER["DOCUMENT_ROOT"];
    //This will get the path where the user is
    if($path == "a"){
    Header("Location: http://url.com/b/");
    //this will redirect the user to b folder
    }
    ?>
    

    This will redirect a user that is in the a folder to the b folder.