|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
sekundek Smarty n00b
Joined: 30 Jun 2004 Posts: 2
|
Posted: Wed Jun 30, 2004 2:38 pm Post subject: add lang to href's |
|
|
Hello!
Our site is multilanguage and I want to make search engine distincts different language. So language code must be in URL. There's no help is user have this in session. Also if german user send an URL to his friend he will see site in default language.
Because of that I made little script to handle URLs correctly:
Code: |
session_start();
$lang = 'lang_code';
if (!empty($_SESSION['lang'])) {
$lang = $lang = $_SESSION['lang'];
}
if (empty($_SERVER["QUERY_STRING"])) {
$redirect = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"].'?lang='.$lang;
Header('Location: '.$redirect);
} elseif (!preg_match('/lang=/i',$_SERVER['QUERY_STRING'])) {
$redirect = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"].'&lang='.$lang;
Header('Location: '.$redirect);
} elseif (preg_match('/lang=/i',$_SERVER['QUERY_STRING'])) {
$_SESSION['lang'] = $_GET['lang'];
}
|
It work OK, but the only problem is redirection. Page Hits are doubled.
Is there any way to handle this. Maybe with smarty or php directly. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|