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

MII Netweaver Server stopped due to CPIC connection Problem
Dear Experts,
We have SAP XMII 12.0 setup running on Netweaver 2004s,7.0, Java Stack only.

DirectoryIterator and Hacked Website
Hi Everyone.

My problem:
Some one has been sneaking in to my website hidden Iframes. I've

Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related codi

that old Malformed Headers problem again!!!!! HELP!!!!!!
I've read the http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

I don't think my c

PHP Session Issue
I'm having an issue with one section on my website dealing with sessions. Now I know that myself and

if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

Help with writing "$" with fopen
I just can't get my syntax correct. Could someone help me please? I am trying to write a connect fil

"GROUP BY" in arrays
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql

Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I

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