Multilingual + Country wise SEO URL Solution:
Examplehttps://www.samijeweller.com.com/index.php?loc=pk&lang=enHere I did deep research that how can I use PHP for Multilingual websites?
But we need to keep in mind some topics like
- User IP Address Function
- User Language Function
- IP to XML
- XML to PHP Array Conversion
- URL Concept
- Language And Area codes concept
<?php
//Redirect by language
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
//redirect by IP
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$ip = $_SESSION['ip'];
$data = file_get_contents("http://api.hostip.info/get_html.php?ip=".$ip."&position=true");
$arrayofdata = explode("\n", $data);
$country = explode(":", $arrayofdata[0]);
$count = explode(" ", $country[1]);
if(!isset($_GET['lang']) AND !isset($_GET['loc']))
{
//Retrieve location, set time
if(empty($count))
{
header("location: index.php?loc=us-en&lang=".$lang);
exit;
}
else
{
header("location: index.php?loc=".strtolower(trim($count[2],"()"))."&lang=".$lang);
exit;
}
}
?>
Post a Comment
Give your reviews about this blog. Leave your comments. what do you think about this post?
Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe FusionMarketPro.online blog.
---------------------------------------
Thanks for visiting FusionMarketPro.Online.
==========================================
Join Sami Jeweller and Shop online jewelry for your someone special.
==========================================
Best Regards