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 Guidelines:
1) I love to read comments, but please avoid spam.
2) Like this blog, share your insights, and spread the word.
3) You can use basic HTML/xHTML tags.
4) All comments are DoFollow—please use the section professionally.
5) Kindly mention your name or brand below your comment.
6) Constructive suggestions for improvement are always welcome.
7) Do not forget to explore our main agency platform at pingbooster.site.
Thanks for visiting Samee Articles.
========================================
Explore custom digital solutions and WordPress plugins at PingBooster Plugins.
Best Regards,
Samee U. Feroz