PHP Redirection code to create a Multilingual Site. This code is Ready to Put in your website.

Ok let’s go:

<?php

#######################################################
# Multilingual PHP Redirect
# Don't Break My b***s - Gimme Code! Project                                           
# Author: Andrea Tonin - http://blog.lucedigitale.com                                 
# This code come with absolutely no warranty                                            
# If you use this code in your project please give a link to http://blog.lucedigitale.com 
# Thanks in advance                                                                       
#######################################################

# Create language variable
  $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);

# Debug Code - remove hash if you need see $lang value
# echo $lang;
 
# If $lang is "it" go to italian webpage - in all other cases go to english webpage
  if($lang == "it"){
header("Location: http://mypage/it/");
}else{
header("Location: http://mypage/en/"); 
}

?>

$lang will be the ISO 639-1 Language Code. See all list of ISO 639-1 Language Codes >

My official WebSite >