Multi language - seo links


Posted on 16th Feb 2014 07:03 pm by admin

Im trying to figure out the best method to have a multi language website that will function with seo friendly links.

The code that ive used many times before.....

Code: $_SESSION['lang'] = $lang = (isset($_GET['lang']) ?
mysql_real_escape_string(trim($_GET['lang'])) : (isset($_SESSION['lang']) ? $_SESSION['lang'] : 'en')); if (!function_exists("GetSQLValueString"))
which i like as it refreshes the page that the viewer is on and pulls down info form the db with the correct extension i.e. about_en, about_it, about_de etc etc

The problem is when the user changes the language using with the follwing...

Code: if ($_SERVER['QUERY_STRING'])
{

echo "<a href="?{$_SERVER['QUERY_STRING']}&lang=en">EN</a>";
}
else
{

echo "<a href="?lang=en">EN</a>";
}

?></li>
<li><?php if ($_SERVER['QUERY_STRING'])
{

echo "<a href="?{$_SERVER['QUERY_STRING']}&lang=it">IT</a>";
}
else
{

echo "<a href="?lang=it">IT</a>";
}

?></li>
<li><?php if ($_SERVER['QUERY_STRING'])
{

echo "<a href="?{$_SERVER['QUERY_STRING']}&lang=fr">FR</a>";
}
else
{

echo "<a href="?lang=fr">FR</a>";
the page refreshes but with '?lang=it' at the end of the address, therefore im 'presuming' the mod_rewrite will fail...

any ideas of what would be the best solution..

many thanks

No comments posted yet

Your Answer:

Login to answer
182 Like 54 Dislike
Previous forums Next forums
Other forums

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

Entering Data Problem
Code: $result = mysql_query("SELECT * FROM flights");
while ($row = mysql_fetch_array($

Sending an SMS Message with ASP.NET
Often times it may be a requirement for your web application to send an SMS message. Such examples w

Problem with an browser game.
Hello,i just joined that great forum and i got php prob,its kinda freaky...anyway i got browser game

getAlexaRank($url) function not working
I have made a function to get alexa rank
the site is here: http://mytestsite.rack111.com/1

How to assign JS screen.width to ASP.Net variable
I've got this ASP.net routine that gets the cookie value of the screen width, but now I need to chan

Display data returned from Ajaxservices!!
I have a question about displaying results using ajax. I have part of the code below.
$.ajax({

Multiple websites question.
Hi, does php have any functionality that enables a programmer to extract information from a website

how to get sn motherboard
Hello.
I want to get serial number motherboard, cpu and else hardware.
Can You show me sam

Displaying Site Logo/Icon on a Title tag
really need some help out here. I want to insert a Logo/Icon just like the one close to the "PH

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash