PHPackages                             opengento/module-country-store-redirect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. opengento/module-country-store-redirect

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

opengento/module-country-store-redirect
=======================================

This module will redirect the customers regarding their country of origin, on their first visit session.

2.0.1(4y ago)63.9k2MITPHPPHP ^7.4||^8.0

Since Jul 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/opengento/magento2-country-store-redirect)[ Packagist](https://packagist.org/packages/opengento/module-country-store-redirect)[ Docs](https://github.com/opengento/magento2-country-store-redirect)[ RSS](/packages/opengento-module-country-store-redirect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (6)Used By (0)

Country Store Redirect Module for Magento 2
===========================================

[](#country-store-redirect-module-for-magento-2)

[![Latest Stable Version](https://camo.githubusercontent.com/db5bc7fd442860e2d09fb26db25bb19ec7a3bda9723e22747b5887ba29a7f99a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f70656e67656e746f2f6d6f64756c652d636f756e7472792d73746f72652d72656469726563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/opengento/module-country-store-redirect)[![License: MIT](https://camo.githubusercontent.com/6b7c82476cc8c4db01737b48bedb2308b33c40bdb13edc95fec7774b6794c8c4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f70656e67656e746f2f6d6167656e746f322d636f756e7472792d73746f72652d72656469726563742e7376673f7374796c653d666c61742d737175617265)](./LICENSE)[![Packagist](https://camo.githubusercontent.com/ba73319f1855ce366d60d53cd87234f1e96e87bacd4cfc0c12e53134bc727298/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f70656e67656e746f2f6d6f64756c652d636f756e7472792d73746f72652d72656469726563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/opengento/module-country-store-redirect/stats)[![Packagist](https://camo.githubusercontent.com/10dbbdc6847960232f1769c96a9e67e9b034cd4510a4919ea89dfb51936a244a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6f70656e67656e746f2f6d6f64756c652d636f756e7472792d73746f72652d72656469726563742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/opengento/module-country-store-redirect/stats)

This module will redirect the customers regarding their country of origin, on their first visit session.

- [Setup](#setup)
    - [Composer installation](#composer-installation)
    - [Setup the module](#setup-the-module)
- [Features](#features)
- [Settings](#settings)
- [Documentation](#documentation)
- [Support](#support)
- [Authors](#authors)
- [License](#license)

Setup
-----

[](#setup)

Magento 2 Open Source or Commerce edition is required.

### Composer installation

[](#composer-installation)

Run the following composer command:

```
composer require opengento/module-country-store-redirect

```

### Setup the module

[](#setup-the-module)

Run the following magento command:

```
bin/magento setup:upgrade

```

**If you are in production mode, do not forget to recompile and redeploy the static resources.**

### Varnish Usage

[](#varnish-usage)

Update the varnish vcl with the following instruction:

```
# Bypass first visit and redirect
if (req.http.cookie !~ "PHPSESSID=") {
    return (pass);
}

```

Features
--------

[](#features)

### First Session Redirect

[](#first-session-redirect)

Redirect the visitor on its first session visit, depending on its country. This feature can be disabled by store view scope, so the first redirect is only enabled on your main domain for example.

This feature can have non desirable behavior, for example for robots crawling your website. That's why you can set a list of user agents to ignore and to not process the redirection in this case. Moreover, a list of controller actions to ignore is also configurable.

Now you can select which visitor's country resolver to use, the available resolvers are:

- Default Session Country (the country already set in session, or the default for the current store view).
- CloudFare GEO-IP Country (use visitor'scountry available in the HTTP header value). CloudFare Country GEO-IP must be enabled, [see more](https://support.cloudflare.com/hc/en-us/articles/200168236-Configuring-Cloudflare-IP-Geolocation).

Any third party developers can add its own country resolver. Please read the developer section for further details.

### Country to store mapping

[](#country-to-store-mapping)

Define the country to store relation. This configuration will allows Magento to redirect the visitor to the correct store view depending of the visitor's country. Multiple countries can be assigned to a single store view.

Settings
--------

[](#settings)

The configuration for this module is available in `Stores > Configuration > General > Country Redirect`.

Documentation
-------------

[](#documentation)

### How to add a country resolver

[](#how-to-add-a-country-resolver)

Create a new final class and implement the following interface: `Opengento\CountryStoreRedirect\Model\Country\ResolverInterface`. The method `public function getCountryCode(): string` should returns the visitor's country code of origin. The country should be compliant to ISO 3166-1 alpha-2 format.

Register the new country resolver in the method factory, `Vendor/Module/etc/di.xml`:

```

            Vendor\Module\Model\Country\Resolver\CustomCountryResolver

```

If you want the resolver ba available in settings, register it in the resolver list `Vendor/Module/etc/di.xml`:

```

                Custom Country Resolver
                Vendor\Module\Model\Country\Resolver\CustomCountryResolver::RESOLVER_CODE

```

The country resolver is ready to use.

SEO and Performance
-------------------

[](#seo-and-performance)

We strongly discourage you to use the first visit redirect as it is considered harmful and bad practice. Instead show a dialog to allow the visitor to select the country of its preference.
This feature is available in our module [Opengento\_CountryStoreSwitcher](https://github.com/opengento/magento2-country-store-switcher) `opengento/module-country-store-switcher`.

Support
-------

[](#support)

Raise a new [request](https://github.com/opengento/magento2-country-store-redirect/issues) to the issue tracker.

Authors
-------

[](#authors)

- **Opengento Community** - *Lead* - [![Twitter Follow](https://camo.githubusercontent.com/f582f22fdefea808310d5426ff86d748569ab584a65c28c30eb34b72a73ba802/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f6f70656e67656e746f2e7376673f7374796c653d736f6369616c)](https://twitter.com/opengento)
- **Thomas Klein** - *Maintainer* - [![GitHub followers](https://camo.githubusercontent.com/e0e283f9de9d23a7bfeac3e6088a3a3a6844c123e1861f866242cd80e3361088/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f6c6c6f776572732f74686f6d61732d6b6c312e7376673f7374796c653d736f6369616c)](https://github.com/thomas-kl1)
- **Contributors** - *Contributor* - [![GitHub contributors](https://camo.githubusercontent.com/ab8e9305ac4e8be1cd875d17feed831b9089fb16ca4cf9b2e8dc8dfeba406660/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6f70656e67656e746f2f6d6167656e746f322d636f756e7472792d73746f72652d72656469726563742e7376673f7374796c653d666c61742d737175617265)](https://github.com/opengento/magento2-country-store-redirect/graphs/contributors)

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) details.

***That's all folks!***

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~108 days

Total

5

Last Release

1678d ago

Major Versions

1.0.2 → 2.0.02021-10-01

PHP version history (2 changes)1.0.0PHP ^7.4

2.0.0PHP ^7.4||^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/95669?v=4)[Thom](/maintainers/thomasklein)[@thomasklein](https://github.com/thomasklein)

---

Top Contributors

[![thomas-kl1](https://avatars.githubusercontent.com/u/20971693?v=4)](https://github.com/thomas-kl1 "thomas-kl1 (11 commits)")

---

Tags

countrymagentomagento-2magento-extensionmagento-modulemagento2magento2-extensionmagento2-extension-freemagento2-moduleredirectredirectionstorephpgeoipmagentolocationcountryredirectmagento2geoip-location

### Embed Badge

![Health badge](/badges/opengento-module-country-store-redirect/health.svg)

```
[![Health](https://phpackages.com/badges/opengento-module-country-store-redirect/health.svg)](https://phpackages.com/packages/opengento-module-country-store-redirect)
```

###  Alternatives

[opengento/module-gdpr

Gdpr Compliance Module for Magento 2

14481.5k](/packages/opengento-module-gdpr)[run-as-root/magento2-prometheus-exporter

Magento2 Prometheus Exporter

69344.4k](/packages/run-as-root-magento2-prometheus-exporter)[opengento/module-saleable

This extension allows to set if a product is saleable and can show its price by scope and customer group.

136.9k](/packages/opengento-module-saleable)[opengento/module-category-import-export

This module add the capability to import and export the categories from the back-office.

119.1k](/packages/opengento-module-category-import-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
