Can I redirect visitors from specific countries by using .htaccess?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brown Bear
    Confirmed User
    • May 2002
    • 4982

    #1

    Can I redirect visitors from specific countries by using .htaccess?

    I want to redirect visitors from specific countries, can this be done with htaccess? If yes, then what is the code I need?
    Surrender all your independent thinking and Click Here for re-programming.
  • Carrie
    Confirmed User
    • Apr 2002
    • 3162

    #2
    You can use .htaccess to pre-append a php file to be included on all of your pages.
    In that php file you can do the geo-targeting.
    Check out www.maxmind.com for php scripts to geo-target or whip up a self-made solution using Lee's tutorials at ARS Resources.

    Comment

    • Gman.357
      Confirmed User
      • Oct 2002
      • 2796

      #3
      Redirecting by country or region would be hard to do with .htaccess, because of the loose association between IP assignments and countries... but there are services out there that keep up with this, and with some work, you may be able to get a good database of them going.

      These links might be a starting point:

      http://www.ip-to-country.com/
      http://where-is.info/help.html

      Ouch.

      Comment

      • Smegma
        Confirmed User
        • Feb 2002
        • 1751

        #4
        trafficjuicer.com - 3 lines of cut and paste code into html.
        <a href="http://www.jupiterhosting.com"><img src="http://www.jupiterhosting.com/banners/55x55.jupiter.gif" alt="" border="0" align=""></a>

        Comment

        • richard
          Confirmed User
          • Feb 2001
          • 543

          #5
          You can do it based on browser language via .htaccess, but the issue is whether browser language is accurate enough for what you want to do with your traffic.

          If its just being used to block .jp traffic, then htaccess probably is sufficient. If you wanna redirect lots of different countries to different page/show different content, then you need a proper script.

          Hit me up richard {at} ip-sorter.com or icq 41012160 if you wanna chat about foreign country filtering / redirecting / targeting etc.

          Check this url if you're happy with doing it in htaccess: http://www.bowiesnyder.com/writings/nls_apache.htm

          Comment

          Working...