We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

fris on 03/28/08


Tagged

redirect country ban blacklist


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

luman


redirect traffic based on language


Published in: PHP 


  1. <?
  2.  
  3. $languages = array(
  4. 'AF', // africa.
  5. 'AR', // arabic.
  6. 'BG', // bulgarian.
  7. 'CA', // catalan.
  8. 'CS', // czech.
  9. 'DA', // danish.
  10. 'DE', // german.
  11. 'EL', // greek.
  12. 'EN', // english.
  13. 'ES', // spanish.
  14. 'ET', // estonian.
  15. 'FI', // finnish.
  16. 'FR', // french.
  17. 'GL', // galician.
  18. 'HE', // hebrew.
  19. 'HI', // hindi.
  20. 'HR', // croatian.
  21. 'HU', // hungarian.
  22. 'ID', // indonesian.
  23. 'IT', // italian.
  24. 'JA', // japanese.
  25. 'KO', // korean.
  26. 'KA', // georgian.
  27. 'LT', // lithuanian.
  28. 'LV', // latvian.
  29. 'MS', // malay.
  30. 'NL', // dutch.
  31. 'NO', // norwegian.
  32. 'PL', // polish.
  33. 'PT', // portuguese.
  34. 'RO', // romanian.
  35. 'RU', // russian.
  36. 'SK', // slovak.
  37. 'SL', // slovenian.
  38. 'SQ', // albanian.
  39. 'SR', // serbian.
  40. 'SV', // swedish.
  41. 'TH', // thai.
  42. 'TR', // turkish.
  43. 'UK', // ukrainian.
  44. 'ZH' // chinese.
  45. );
  46.  
  47. $lang=split('[,;]',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
  48. $lang=strtoupper($lang[0]);
  49. $lang=split('[-]',$lang);
  50. if (in_array($lang[0], $languages)) {
  51. header('Location: http://www.domain.com/landingpage.html');
  52. }
  53.  
  54. ?>

Report this snippet 

You need to login to post a comment.