Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

add lang to href's

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
sekundek
Smarty n00b


Joined: 30 Jun 2004
Posts: 2

PostPosted: Wed Jun 30, 2004 2:38 pm    Post subject: add lang to href's Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP