Title: redirect using HTTP_ACCEPT_LANGUAGE
Last modified: August 18, 2016

---

# redirect using HTTP_ACCEPT_LANGUAGE

 *  [kalebeul](https://wordpress.org/support/users/kalebeul/)
 * (@kalebeul)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/redirect-using-http_accept_language/)
 * I’m trying to read / set http_accept_language to:
    1) give users text in their
   browser default language; 2) give them the option of changing to another language.
   My code works fine: [http://oreneta.com/kalebeul/test.php](http://oreneta.com/kalebeul/test.php)
   but dies once it goes into a WordPress template (same code/text near bottom right-
   hand column): [http://oreneta.com/kalebeul/2006/10/13/2000-catalan-insults/](http://oreneta.com/kalebeul/2006/10/13/2000-catalan-insults/)
   Here’s my code: `<?php $day=(date('d')); $month=(date('m')); if ($userlang==""){
   $userlang=$_SERVER['HTTP_ACCEPT_LANGUAGE']; $userlang=substr($userlang,0,2); }
   if ($userlang=="es")  { include("http://oreneta.com/libro_verde_bcn/es/$month/
   $day/"); echo "(<small><a href="?userlang=en">Traducción</a>)</small>"; } else{
   include("http://oreneta.com/libro_verde_bcn/en/$month/$day/"); echo "(<small>
   <a href="?userlang=es">Original</a>)</small>"; } ?>
 * Any ideas? I thought at first it was a register globals thing, but not sure now.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [lxg](https://wordpress.org/support/users/mastermind/)
 * (@mastermind)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/redirect-using-http_accept_language/#post-465528)
 * Before you reinvent the wheel: Check the Polyglot plugin:
    [http://www.fredfred.net/skriker/index.php/polyglot](http://www.fredfred.net/skriker/index.php/polyglot)
 *  Thread Starter [kalebeul](https://wordpress.org/support/users/kalebeul/)
 * (@kalebeul)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/redirect-using-http_accept_language/#post-465694)
 * Yeah, I use that somewhere else. Do you know by any chance if it comes up against
   and deals with this issue?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘redirect using HTTP_ACCEPT_LANGUAGE’ is closed to new replies.

## Tags

 * [language](https://wordpress.org/support/topic-tag/language/)
 * [Localization](https://wordpress.org/support/topic-tag/localization/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * 2 replies
 * 2 participants
 * Last reply from: [kalebeul](https://wordpress.org/support/users/kalebeul/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/redirect-using-http_accept_language/#post-465694)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
