php - Google crawl error with HTTP_ACCEPT_LANGUAGE -
in codeigniter app use $_server['http_accept_language']
determine users browser language set app language based on that, that:
public function __construct() { parent::__construct(); /* set session language if not set. "hu" if browser language "hu", else "en" */ if(!($this->session->userdata("lang"))) { $browserlang = substr($_server["http_accept_language"],0,2); if ($browserlang == "hu") { $this->config->set_item("language", "hu"); $this->session->set_userdata("lang", "hu"); $this->lang->load("bh_hu", "hungarian"); } else { $this->config->set_item("language", "en"); $this->session->set_userdata("lang", "en"); $this->lang->load("bh_en", "english"); } } else { switch ($this->session->userdata("lang")) { case "hu": $this->lang->load("bh_hu", "hungarian"); break; case "en": $this->lang->load("bh_en", "english"); break; } } .... }
everything's working fine, google crawler not send http_accept_language
, returns php error undefined index: http_accept_language
when crawling pages.
this nasty, because php error fills entire google search snippet.
is there way let google bot ignore http_accept_language
action?
thanks in advance!
$browser_lang = !empty($_server['http_accept_language']) ? strtok(strip_tags($_server['http_accept_language']), ',') : ''; $browser_lang = substr($browser_lang, 0,2); // check if support language , set if(array_key_exists($browser_lang, $this->languages /* define array compare */)) return $browser_lang; else{ // return default lang }
Comments
Post a Comment