Solving Polylang Redirect Homepage Problem

Why does Polylang redirect to another version of the language? In the polylang plugin for wordpress, there is one small glitch related to the redirect of the main page (Polylang Homepage Redirect)

WordPress site, multilingual implemented by Polylang. automatically redirects to And if you turn on some kind of caching plugin, then language switches do not work at all. Google Page Speed when requesting writes that “The requested URL redirects to the following URL:
One of the forums suggested a solution – disable “Detect browser language” in Polylang. In this case, the language switchers work, but the redirect remains. Moreover, this function is important.

Solution for Polylang Redirect Homepage issue:

Go to plugin editor and select Polylang
go to the file /frontend/frontend-static-pages.php
We find
* Prevents canonical redirection if we are on a static front page
* @since 1.8
* @param string $redirect_url
* @return bool|string
public function pll_check_canonical_url( $redirect_url ) {

We replace the function with a working one
public function pll_check_canonical_url( $redirect_url ) {
return $this->options['redirect_lang'] && ! empty( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ? false : $redirect_url;

Profit, everything works as before.