SitePoint Sponsor

User Tag List

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

    Redirecting to a Different Language Directory

    I'm working on a multi language website and I use directories like www.mysite.com/en/, www.mysite.com/es/, www.mysite.com/de/ 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 www.mysite.com/en/products/product_name.php 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 www.mysite.com/es/products/product_name.php

    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
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    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.


Bookmarks

Posting Permissions

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