1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Ip redirect script?

Discussion in 'Hire a Freelancer' started by wealthy199, Jul 14, 2008.

  1. wealthy199

    wealthy199 BANNED BANNED

    Joined:
    Sep 24, 2007
    Messages:
    585
    Likes Received:
    1,088
    Can someone make me a php script which allows me to list various ips to redirect to a certain page of my site rather then the default page?

    For example if a user comes from 234.123.43.53 and goes to http://mysite.com/page1.php and they are listed in my script they should be redirected to a page such as http://mysite.com/page2.php.

    Anyone want some quick money?
     
  2. IsoRipper

    IsoRipper Junior Member

    Joined:
    Feb 4, 2008
    Messages:
    184
    Likes Received:
    103
    Location:
    Bloody England
    Do you have the exact IPs? I can do this for ya Bro
     
  3. wealthy199

    wealthy199 BANNED BANNED

    Joined:
    Sep 24, 2007
    Messages:
    585
    Likes Received:
    1,088
    I don't have them yet, but I'll manually add them when I need to.
     
  4. IsoRipper

    IsoRipper Junior Member

    Joined:
    Feb 4, 2008
    Messages:
    184
    Likes Received:
    103
    Location:
    Bloody England
    Alright Bro, as talked over MSN, I will get back to u shortly!
     
    • Thanks Thanks x 1
  5. ★WiM★

    ★WiM★ Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 8, 2008
    Messages:
    462
    Likes Received:
    457
    Occupation:
    CPA Network
    Location:
    Europe
    simpletds.com use it fo free
     
    • Thanks Thanks x 1
  6. navin

    navin Junior Member

    Joined:
    Mar 15, 2007
    Messages:
    106
    Likes Received:
    25
    that didn't seem like english to me, nor did google translate could do a good job.

    anyone here have any other suggestions?

    a scrupt like that would be very nice :)
     
  7. Orebil

    Orebil Registered Member

    Joined:
    Jul 13, 2008
    Messages:
    66
    Likes Received:
    13
    Occupation:
    Web Developer
    Location:
    USA
    A much easier way is to use in_array(). No loops necessary. I prefer to use databases, but for simplicity I'll keep it with an array:

    Code:
    <?php
    //add ips, to your list here, separating each with by a comma
    $ip_array = array('255.255.255.255', '0.0.0.0');
    
    //if they made it past the while loop, then the ip didnt match, send them to page1.php
    if (in_array($_SERVER['REMOTE_ADDR'], $ip_array)) {
    	header('Location: http://www.yoursite.com/page1.php');
    }
    ?>
    His actual request was for associating different pages with different IPs. This is a one to many relationship (page -> n..*). This would require a different array setup, or as I mentioned above a better way would be a database.

    Wealthy, if you want something a bit more extensive let me know. I'm always looking to pickup side projects.
     
    Last edited: Jul 15, 2008
  8. JohnDoe

    JohnDoe Junior Member

    Joined:
    Dec 28, 2007
    Messages:
    159
    Likes Received:
    21
    Could you do some thing like this in your htaccess


    PHP:
    RewriteEngine on
    # If not googlebot IP address number 1
    RewriteCond %{REMOTE_ADDR} !^66\.249\.65\.133$
    # And if not googlebot IP address number 2
    RewriteCond %{REMOTE_ADDR} !^66\.249\.67\.72$
    # Then redirect all other requests to another page

    RewriteRule !^page1http://www.mysite.com/page2/ [R=301,L]