SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    0 Post(s)
    0 Thread(s)

    Redirecting to a Different Language Directory

    I'm working on a multi language website and I use directories like,, to hold the different language versions.

    I'd like the user to be able to change the language from every page in the website and on changing the language to be redirected to the exactly the same page but in the newly chosen language.

    For example if the user is at he/she should be able to chose a different language from there and if he/she does so, for example if he/she choses Spanish, he should be redirected to

    What would be the best way to achieve that?

    Thank you!

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    France, deep rural.
    17 Post(s)
    1 Thread(s)
    make a page called redirect.php

    When user selects a language, from say a drop down, then send to redirect.php.

    Send along with the request

    the url of this page "/en/products/prod1.php"
    The selected lang code es.

    Get redirect.php to ;

    check the incoming vars!
    set a new cookie with lang=es
    chop off the /en/ from the incoming url
    add /es/ to it
    redirect the user.


Posting Permissions

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