• Hi all, I wrote this redirect function which sort of works

    function underConstruction()
    {
        $visitor = $_SERVER['REMOTE_ADDR'];
        $valid_ips = array("1","2","3","4");
    
        if(!in_array($visitor, $valid_ips))
        {
            header("Location: http://www.redirecthere.com");
        }
    }

    I’ve removed the IP addresses. Now this…kind of works. It works if I try to access any other page of the site other than the home page from a non valid IP. When accessing the home page, I get an error stating that the headers cannot be modified as they’ve already been sent. Anyone else ever had this issue?

Viewing 1 replies (of 1 total)
  • Thread Starter creativelifeform

    (@creativelifeform)

    Okay have modified the code to use Javascript redirection (eventhough I think that is lame), just replace the header function with this

    ?>
            <script type="text/javascript">window.location = "http://www.redirecthere.com"</script>
            <?php
Viewing 1 replies (of 1 total)

The topic ‘IP based redirect’ is closed to new replies.