PageSpeed broken after implementing redirect

[ad_1]

I use Polylang for translating content on a clients website. However, the client requested that users should be redirect on their initial visit based on their region (by IP address).

I’ve implemented some custom code that works, but it does break tools like PageSpeed. When trying to scan the website, PageSpeed will load for a very long time and eventually gives the error message `Unable to resolve . Try checking the URL for validity.`.

This is my code: [Gist Github])

The function `wp_safe_redirect` is the line that causes it. Somehow I think PageSpeed occurs in a infinite loop, because it can’t set cookies. Can someone help?

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer