0
Welcome Guest! Login
0 items Join Now

Redirect Visitors Based on IP?

    • Terp's Avatar
    • Terp
    • Elite Rocketeer
    • Posts: 1720
    • Thanks: 23

    Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • Short of using an extension, is it possible to redirect would-be visitors to another site based on their IP address/range?

      I used to do on my DNN sites, but knowing web.configs and not htaccess stuff, I thought I would ask if I could drop some php in there to get 'er done. Something like this work?
      <?
      $visitor = $_SERVER['REMOTE_ADDR'];
      if (preg_match("/96.xxx.xx.xx/",$visitor)) {
      &nbsp; &nbsp; &nbsp; header('Location: http://www.fbi.gov');
      } else {
      &nbsp; &nbsp; &nbsp; header('Location: http://www.myURL.com');
      };
      ?> 
    • Franck's Avatar
    • Franck
    • Elite Rocketeer
    • Posts: 1049
    • Thanks: 0

    Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • Hi Terp,

      Look at this page to find some useful articles www.ip2location.com/articles.aspx

      I'm using the IP2location database on one of my website to block all non US users on certain pages. If you want to redirect users to another website it's more easy than block or redirect certain pages. IP2location database is commercial but you will receive a monthly update. Very god product. ;)
    • damo's Avatar
    • damo
    • Elite Rocketeer
    • Posts: 2142
    • Thanks: 0

    Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
  • Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • Just a curious question, would redirecting visitors base on country or IP an ideal thing to do? Lots of companies now have single internet connection within region or corporation like us, we are base in Sydney but our internet connection goes out of Singapore that will mean we get redirected to Singapore specific site.

      I already experience this, accessing an Australia site and was not allowed to do transaction because it says I am out of Australia???
    • damo's Avatar
    • damo
    • Elite Rocketeer
    • Posts: 2142
    • Thanks: 0

    Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • sometimes people are forced to do country redirect or sometimes people just dont want to deal with a specific country

      i think these things are used more out of necessity rather than anything else
    • www.c3p0.se - sweden
    • Franck's Avatar
    • Franck
    • Elite Rocketeer
    • Posts: 1049
    • Thanks: 0

    Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • I need to restrict some pages due to copyright reasons. I just have no choice.
      Like Damo said, some webmasters don't want to deal with some countries. Others prefer to redirect the visitors in a page or website with the proper language (Google, Yahoo and many other sites).
  • Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • never really had the need so did not have to deal with. thanks for the good views.
    • Terp's Avatar
    • Terp
    • Elite Rocketeer
    • Posts: 1720
    • Thanks: 23

    Re: Redirect Visitors Based on IP?

    Posted 16 years 7 months ago
    • Thanks everyone...lots to look into and have some great leads.

Time to create page: 0.059 seconds