O
O
oxxoll2021-12-10 20:22:27
PHP
oxxoll, 2021-12-10 20:22:27

How to make HTTP_ACCEPT_LANGUAGE redirect correctly?

Greetings!

Need help!)

There is such a thing, but I would like it to let bots through!

preg_match('/^\w{2}/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $m);
switch (strtolower($m[0])) {
case 'ru': break;
default: header('Location: /en'); break;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2021-12-10
@oxxoll

add a check for "bot|spider|crawler" to HTTP_USER_AGENT, but instead of $_SERVER it's better to use filter_input(INPUT_SERVER, 'HTTP_USER_AGENT')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question