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

Ok let’s go:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?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 >