SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirecting users

    Hi guys!

    I would like to redirect users based on the state they are in to another website address as well as exclude an IP address so they can access my site.

    I have js API code from MaxMind, but I'm not sure how to do the rest:

    Code:
    <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
    <script language="JavaScript">document.write(geoip_region());</script>
    An example:

    Redirect users from PA, DE and NJ to Google.com but exclude IP address 174.343.198.99 so they can access the website even if they are in one of those states.

    Another example:

    Redirect users from FL to Google.com, but exclude IP address 123.123.123.12 so they can access even if they are in FL.

    Thank you SO MUCH!

    -Jennifer

  2. #2
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any reason why this couldn't be done in php, or another server side script? It would be a lot easier and faster. In PHP, the IP address is available as $_SERVER['REMOTE_ADDR'], and it is very easy to get a location from an IP address using:

    $ip = @FiL e_get_contents("http://automation.whatismyip.com/n09230945.asp");

    All you have to do is parse what is returned and you have your state.

  3. #3
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi - I already have a PHP script but it doesn't work good enough. The api for maxmind connects to their full database which is a lot more accurate than free services.

  4. #4
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Does maxmind have a PHP version of their API?

    While javascript would certainly work, doing redirects on the server is always better (faster and more reliable)



    Sent from my Desire HD using Tapatalk
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  5. #5
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They have this: http://www.maxmind.com/app/php

    But it requires you to download their free lite databases to use which is not what I want to do. I already use their "lite" free databases and they do not work right. I get about 1,000 people a month from the state I don't want that don't get redirected.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •