Browser detection and Redirection using Javascript

Discussion in 'JavaScript' started by johntropea, Oct 29, 2011.

  1. #1
    Hi everybody,
    I'm setting a new site in 2 languages French- English.
    The main site is in French:
    httt://mainsite.com

    the second language (english) is in a subfolder:
    httt://mainsite.com/en

    I'm looking for a Javascript that detect and redirect to newsite(.)com/en all the users that aren't french
    and of course allow the french users go to the main site newsite(.)com

    Could you please help me?
    Thanks in advance
     
    johntropea, Oct 29, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    What would be your logic to identify the users that aren't french?


    Anyways, I would suggest following:

    1. Use server side checking in PHP.
    2. Based on IP address of user, check which country user belongs to.
    3. If user is from France, show default page, else redirect to /en
    4. You can also give option to set default language and drop it in cookie which you can read before doing IP to country check.

    For IP to Country mapping, you can use MaxMind database.
     
    mastermunj, Oct 29, 2011 IP
  3. johntropea

    johntropea Active Member

    Messages:
    546
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    68
    #3
    getting default browser language, not possible?
     
    johntropea, Oct 29, 2011 IP