justbetter / statamic-detour
Statamic addon for redirects.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/justbetter/statamic-detour
Requires
- php: ^8.3
- laravel/framework: ^12.0
- spatie/simple-excel: ^3.8
- statamic/cms: ^5.67.0
Requires (Dev)
- larastan/larastan: ^3.4
- laravel/pint: ^1.22
- orchestra/testbench: ^10.3
- pestphp/pest: ^3.7
- phpstan/phpstan-mockery: ^2.0
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2026-02-04 09:03:52 UTC
README
This Statamic addon provides a flexible redirect management system for your Statamic projects.
Requirements
- PHP ^8.3
- Laravel ^12.0
- Statamic ^5.67.0
Features
- Performance Mode: Ensure redirects are only checked after Statamic determines a route doesn't exist (prevents slowing down valid hits)
- Multi-Site/Locale Support: Redirects can be global or scoped to a specific site handle
- Storage Driver: Option to store redirects in flat files (YAML) for version control OR Database for performance on massive sites
- Path & Regex Support: Create redirects using simple paths or powerful regex patterns
- Multiple Redirect Codes: Support for 301, 302, 307, and 308 redirect codes
- Control Panel Interface: Manage redirects directly from the Statamic Control Panel
Installation
You can install this addon via Composer:
composer require justbetter/statamic-detour
Configuration
You can publish the config by running:
php artisan vendor:publish --tag=justbetter-statamic-detour
You can now find the config file at config/statamic-detour.php.
Storage Driver
The package supports two storage drivers:
File Driver (Default)
Store redirects as YAML files in your content directory. This is ideal for version control and smaller sites.
return [ 'driver' => 'file', 'path' => base_path('content/detours'), ];
Or set via environment variable:
STATAMIC_DETOUR_DRIVER=file
Eloquent Driver
Store redirects in the database. This is recommended for larger sites with many redirects for better performance.
return [ 'driver' => 'eloquent', ];
Or set via environment variable:
STATAMIC_DETOUR_DRIVER=eloquent
When using the Eloquent driver, run the migrations:
php artisan migrate
Performance Mode
The package supports two modes for checking redirects:
Basic Mode (Default)
Redirects are checked early in the request lifecycle, before Statamic's routing.
return [ 'mode' => 'basic', ];
Or set via environment variable:
STATAMIC_DETOUR_MODE=basic
Performance Mode
Redirects are only checked after Statamic determines a route doesn't exist. This prevents slowing down valid route hits.
return [ 'mode' => 'performance', ];
Or set via environment variable:
STATAMIC_DETOUR_MODE=performance
Usage
Creating Redirects
Navigate to Tools > Detours in the Statamic Control Panel to manage your redirects.
Path Redirects
Create simple path-based redirects:
- From:
/old-page - To:
/new-page - Type: Path
- Code: 301 (or 302, 307, 308)
- Sites: Leave empty for global, or select specific sites
Regex Redirects
Create powerful pattern-based redirects:
- From:
/blog/(\d{4})/(\d{2})/(.*) - To:
/articles/$1/$2/$3 - Type: Regex
- Code: 301
- Sites: Select specific sites if needed
Multi-Site Support
When creating a redirect, you can:
- Leave Sites empty: The redirect will apply globally to all sites
- Select specific sites: The redirect will only apply to the selected site handles
This allows you to manage redirects per site in a multi-site Statamic installation.
Storage Considerations
File Driver
- Redirects are stored as YAML files in
content/detours/ - Each redirect is a separate file
- Perfect for version control
- Best for smaller sites (< 100 redirects)
Eloquent Driver
- Redirects are stored in the
detoursdatabase table - Better performance for large numbers of redirects
- Recommended for sites with 100+ redirects
- Supports faster lookups and queries
Quality
To ensure the quality of this package, run the following command:
composer quality
This will execute three tasks:
- Makes sure all tests are passed
- Checks for any issues using static code analysis
- Checks if the code is correctly formatted
Credits
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.