How To Make Country Wise Website on Same Domain

Country Wise Website Using PHP | Hello everyone ,welcome to another fresh article ,in this article I will teach you how to make a simple country wise website on php, for example, visitor visit your website in India, so it’s automatic redirect to India version like domian.com/hi and if visitor visit your website outside of India like in us and another country so it automatically redirects to root domain or domian.com/en.

it’s a very simple process, here is simple code, you can use in your index file, just copy and paste below code in your website index file it’s automatic worked, on India and us ,also you can modify this code as per your choice ,mean’s you can add more country on switch case.

Note: Learn in details about making this type website, so you need to watch below video, so please watch below video, video language is hindi, I will try to add subtitles soon.


<?php

  $user_ip = getenv('REMOTE_ADDR');
  $geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
  $country = $geo["geoplugin_countryName"];

  switch ($country) {
    case "India":
        header('Location:http://domain.com/hi');
        break;
    case "United States":
        header('Location:http://domain.com/en');
        break;
    default:   
        header('Location:http://domain.com');  
  }

?>

Watch a Video

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

Editorial Staff at Veewom is a Team of Experts led by Bharat Makvana.

You may also like this!