Country based redirection from a proxied domain

  • Site name: site-agicap-com-production.netlify.app
  • Domain: agicap.com

We have a site that is translated into multiple languages. We have set the redirection based on the Country which is working properly on the Netlify domain (site-agicap-com-production.netlify.app). The main domain (agicap.com) is linking with the Netlify domain behind a proxy, because of which the redirection is not working.

Is there anything we can pass to Netlify along with the request from the main domain so that the redirections work properly? Can we use the X-Forwarded-For header for this?

Any help will be highly appreciated.

Hi @vishal.deep,

You can use the cookie to redirect: Redirect options | Netlify Docs.

Hi @hrishikesh, thank you for your response.

We are already using cookie-based redirection when the user selects a language from the language dropdown.

The issue is that the user then has to explicitly select the desired language. We are hoping to redirect the users to their country page automatically.

Is there any way we can leverage the GeoIP based redirection that Netlify supports out-of-the-box?

Hi @vishal.deep,

Unfortunately, when you proxy to Netlify, we can see the IP address of the proxying agent and not the actual user. Thus, the location based redirect won’t work with proxy as it relies on IP address.

The only other way would be to ask the user for language preferences on initial website load and save it in a cookie.

1 Like