liquidbcn / craftcms-language-redirect
Simple language redirector based on browser preferences
Installs: 597
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 3
Open Issues: 4
Type:craft-plugin
pkg:composer/liquidbcn/craftcms-language-redirect
Requires
This package is auto-updated.
Last update: 2025-12-11 14:20:48 UTC
README
Redirects users to localized URLs based on browser language preferences. When a user visits your site's root path (/), the plugin detects their browser language and redirects them to the appropriate localized URL.
Requirements
- Craft CMS 5.0.0 or later
- PHP 8.2 or later
Installation
composer require liquidbcn/craftcms-language-redirect
Then go to Settings → Plugins and click "Install".
Configuration
Option 1: Control Panel (recommended)
Go to Settings → Plugins → Language Redirect and configure:
- Default Language: Fallback locale if browser language isn't in your URL list (e.g.,
en-GB) - Language URLs: Map locale codes to your site URLs
Option 2: Config file
Create config/language-redirect.php:
<?php return [ 'defaultLanguage' => 'en-GB', 'urls' => [ 'ca' => '/ca/', 'ca-ES' => '/ca/', 'es' => '/es/', 'es-ES' => '/es/', 'en-GB' => '/en/', 'en-US' => '/en/', 'en' => '/en/', ], ];
Config file settings take precedence over Control Panel settings.
How it works
- User visits your site root (
/) - Plugin reads the
Accept-Languageheader from the browser - Matches against your configured locale mappings
- Performs a 301 redirect to the corresponding URL
The plugin only triggers on GET and HEAD requests to the root path.
License
MIT
Developed by Liquid Studio