Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Domain redirect (language dependent) help!

    Hello to all!

    I'm trying to setup my new php site, which is bilingual (english/french) in a way that each of the separate language versions use different domains (which I already have - two domains and one install of the site).

    Right now my site is functioning with manual language switching.

    Thou I'm not good enough with php I suppose that the language versions are maintained on the session level. So I got something like this: .mysite.com/index.php?lang=en for english and .mysite.com/index.php?lang=fr for french version.

    What I want to do is apply some kind of apache/php/.htaccess redirects in my site so that when users select english domain(www.mysite.com) the english language is automatically selected, and when they go to the french domain(www.monsite.com) to switch to french version.

    Is this possible??

    Thank you in advance!

  • #2
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    You could check to see what the domain is, and depending on what it is, you could use a session variable to keep track of what language needs to be used. Something like this:

    PHP Code:
    session_start();

    $domain $_SERVER['HTTP_HOST'];

    if (
    $domain == 'mysite.com') {
       
    $_SESSION['language'] = 'en';
    } elseif (
    $domain == 'monsite.com') {
       
    $_SESSION['language'] = 'fr';
    }

    $language $_SESSION['language'];

    //Then, include the correct language file
    include_once('languages/' $language '.php'); 

  • #3
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by JohnDubya View Post
    You could check to see what the domain is, and depending on what it is, you could use a session variable to keep track of what language needs to be used. Something like this:

    PHP Code:
    session_start();

    $domain $_SERVER['HTTP_HOST'];

    if (
    $domain == 'mysite.com') {
       
    $_SESSION['language'] = 'en';
    } elseif (
    $domain == 'monsite.com') {
       
    $_SESSION['language'] = 'fr';
    }

    $language $_SESSION['language'];

    //Then, include the correct language file
    include_once('languages/' $language '.php'); 
    Thanks a milion man!! This actually worked

    Cheers!

  • #4
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Glad I could help. Good luck!


  •  

    Posting Permissions

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