PHPackages                             jorisnoo/craft-locale-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. [Localization &amp; i18n](/categories/localization)
4. /
5. jorisnoo/craft-locale-redirect

ActiveLibrary[Localization &amp; i18n](/categories/localization)

jorisnoo/craft-locale-redirect
==============================

Browser locale detection and redirect for Craft CMS

00[1 PRs](https://github.com/jorisnoo/craft-locale-redirect/pulls)PHPCI failing

Since Mar 18Pushed 1mo agoCompare

[ Source](https://github.com/jorisnoo/craft-locale-redirect)[ Packagist](https://packagist.org/packages/jorisnoo/craft-locale-redirect)[ RSS](/packages/jorisnoo-craft-locale-redirect/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Craft Locale Redirect
=====================

[](#craft-locale-redirect)

A Craft CMS module that automatically redirects visitors from `/` to their locale-specific home route based on their browser language preferences.

Features
--------

[](#features)

- Detects the visitor's preferred language from the `Accept-Language` header
- Matches it against your Craft multi-site locales
- Redirects from `/` to the best-matching locale home URL (e.g. `/en`, `/fr`, `/de`)
- Skips bots and crawlers to preserve SEO
- Configurable locale exclusions and restrictions
- Zero configuration required for basic usage

Requirements
------------

[](#requirements)

- PHP 8.2+
- Craft CMS 4 or 5

Installation
------------

[](#installation)

```
composer require jorisnoo/craft-locale-redirect
```

Then register the module in your `config/app.php`:

```
return [
    'modules' => [
        'locale-redirect' => \Noo\CraftLocaleRedirect\Module::class,
    ],
    'bootstrap' => ['locale-redirect'],
];
```

How It Works
------------

[](#how-it-works)

When a visitor hits your site's root URL (`/`), the module:

1. Reads the `Accept-Language` header from the browser
2. Fetches all configured Craft site locales and their URLs
3. Finds the best match between browser preferences and available locales
4. Issues a `302` redirect to the matched locale's home URL

If no match is found, the visitor is redirected to the primary site's URL (or a configured fallback).

Bots and crawlers are automatically excluded from redirection so they can index your root URL normally.

Configuration
-------------

[](#configuration)

The module works out of the box with no configuration. To customize behavior, create a `config/locale-redirect.php` file in your Craft project:

```
