...

View Full Version : Domain redirect (language dependent) help!



kinaski
03-11-2008, 03:17 AM
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!

JohnDubya
03-12-2008, 03:25 PM
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:



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');

kinaski
03-12-2008, 10:01 PM
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:



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!

JohnDubya
03-12-2008, 10:03 PM
Glad I could help. Good luck! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum