jorisnoo/statamic-locale-redirect 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jorisnoo/statamic-locale-redirect

最新稳定版本:0.1.1

Composer 安装命令:

composer require jorisnoo/statamic-locale-redirect

包简介

A Statamic addon that redirects visitors to the locale-specific home route.

README 文档

README

A Statamic addon that automatically redirects visitors from / to their locale-specific home route based on their browser language preferences.

Features

  • Detects the visitor's preferred language from the Accept-Language header
  • Matches it against your Statamic multi-site locales
  • Redirects from / to the best-matching locale home URL (e.g. /en, /fr, /de)
  • Preserves query parameters through the redirect
  • Configurable locale exclusions and restrictions
  • Zero configuration required for basic usage

Requirements

  • PHP 8.2+
  • Statamic 5 or 6

Installation

composer require noordermeer/statamic-locale-redirect

That's it. The addon registers itself automatically via Laravel's package discovery.

How It Works

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

  1. Reads the Accept-Language header from the browser
  2. Fetches all configured Statamic 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 default site's URL (or a configured fallback). Query parameters are preserved through the redirect.

Configuration

The addon works out of the box with no configuration. To customize behavior, publish the config file:

php artisan vendor:publish --tag=locale-redirect

This creates config/statamic/locale-redirect.php:

return [
    'exclude' => [],
    'only' => [],
];

Exclude Locales

Prevent specific locales from being redirect targets:

'exclude' => ['de', 'it'],

Restrict to Specific Locales

Only allow redirection to specific locales. When set, only takes precedence over exclude:

'only' => ['en', 'fr'],

Testing

./vendor/bin/phpunit

License

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 154
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固