Php redirect to different urls??

by Jute
6 replies
Hi,

I have a site where I do product reviews.

I use a php to redirect....

PHP Code:
<?php header'Location: Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more' ) ;?>
What I would like to know is if there is a way to set it up so that if the visitor comes from canada it will redirect him to one url and if he comes from us to another url...

Any ideas would be much appriciated! php code? other code? Wordpress Plugin? etc etc

Thanks in advance!

Jute
#php #redirect #urls
  • Profile picture of the author CarloD.
    This may help:
    find county using ip address - PHP

    You need to use geoip

    basically get the ip match it to a country and then create a script to say if it US redirect them to the US amazon site, or if its Canada redirect them to amazon.ca
    Signature

    {{ DiscussionBoard.errors[2627070].message }}
  • Profile picture of the author dealbert.net
    MaxMind includes free geoip to country and city database. Haven't used it personally. You can give it shot. Link: MaxMind - GeoIP PHP API
    {{ DiscussionBoard.errors[2627581].message }}
    • Profile picture of the author Jute
      Hi,

      Thanks for your replies.

      I am not a coder so I was looking more for a script or a solution that I could buy and put on my sites....

      Any ideas of where I might find that?

      Thanks

      Jute
      {{ DiscussionBoard.errors[2627814].message }}
      • Profile picture of the author gfsocial
        max mind has a pretty straight forward "how to install"... otherwise you are likely going to need someone to do this for you... as this does take coding..
        {{ DiscussionBoard.errors[2628265].message }}
        • Profile picture of the author CarloD.
          Ok not sure why but i can never post code to this forum..... it just doesn't work for me in firefox IE or chrome....

          See attachment

          2 functions. 1st one gets the ip second finds and displays where they are.

          the bit of code at the bottom gets the real IP: ripadd=getRealIpAddr();

          then the last three lines take the ip run the function to find locaiton and then display them

          You would now need to take the returned data and create a script to do the redirection.

          If it's US then redirect them here ELSE redirect them here.

          this will all depend on what you are going for. don't think there is a buying solution for this, it would need to be created.



          That's a start and can achieve what you are trying to do, it's just incomplete, I am aware you don't know the coding. I don't have much more time do this today. so maybe that will help you out.

          You would need to do this per new product review, I can help you finish this but would require a small fee, just for the time, if interested PM.

          It can take a bit of time, and I have 1000 other things on my plate but i can probably help you out if interested.

          just PM me
          Signature

          {{ DiscussionBoard.errors[2628561].message }}

Trending Topics