magento - PHP Redirecting by Accept_Language -
ok, i'm new php please bear me if make basic mistakes here:
i'm trying magento 1.9.x shop redirect substore language. i've made this:
function checkstorelanguage() { $result = ''; if (isset($_server['http_accept_language'])) { $langstring = strtolower(substr( $_server["http_accept_language"],0,2 )); if($langstring == 'da'){ $result = '/dk'; } elseif ($langstring == 'en'){ $result = '/uk'; } else { $result = '/eu'; } } return $result; } if ($_server['request_uri'] === '/') { header('location: '.checkstorelanguage()); exit; } now seems working in incognito-mode not in normal mode might cache thing, can cache affect server redirection , how avoid that?
you can set http-response code 303 tell browser shouldn't cached.
the 303 response must not cached, response second (redirected) request might cacheable.
within php:
header('location: ' . checkstorelanguage(), true, 303); by way: code redirects 'empty string' when there no accept-language-header present in request. might want change initializing $result-variable (default?) 'eu'. $result = 'eu' instead of $result = ''.
Comments
Post a Comment