Redirect domain

Hello,

Kindly could you please help as as we are new with Slim Framework.
We have a multi language site.
We would like to redirect our domain directly to one of the pages.

For example mydomain.com ( is in english) i want when end user call mydomain.com it redirects to mydomain.com/gr wich is the greek version of the site.

How to do this?

You can look into the Maxmind Geo IP database, that will allow you to determine the visitors country by IP address: https://packagist.org/packages/geoip2/geoip2

Maxmind offers a free database for this use case you can try.

A way to use this would be using middleware on the route for mydomain.com:

  1. If session value visitor_country is not set:
    1.1 Determine visitor country using geo ip
    1.2 Set session value visitor_country (set to “unknown” if it could not be determined)
  2. Based on visitor_country redirect to mydomain.com/{country_code}