PHPackages                             justbetter/statamic-detour - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. justbetter/statamic-detour

ActiveLibrary[HTTP &amp; Networking](/categories/http)

justbetter/statamic-detour
==========================

Statamic addon for redirects.

0.5.1(2w ago)2698↑97.6%PHPPHP ^8.4CI passing

Since Jan 28Pushed 2w agoCompare

[ Source](https://github.com/justbetter/statamic-detour)[ Packagist](https://packagist.org/packages/justbetter/statamic-detour)[ RSS](/packages/justbetter-statamic-detour/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (27)Versions (16)Used By (0)

Statamic Detour
===============

[](#statamic-detour)

[ ![JustBetter logo](./art/header.png)](https://justbetter.nl "JustBetter")This Statamic addon provides a flexible redirect management system for your Statamic projects.

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

[](#requirements)

- PHP ^8.3
- Laravel ^12.0
- Statamic ^6.3

Features
--------

[](#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 &amp; Regex Support**: Create redirects using simple paths or powerful regex patterns
- **Multiple Redirect Codes**: Support for 301, 302, 307, and 308 redirect codes
- **Query String Handling**: Pass through, strip completely, or strip specific keys (for example `gclid`)
- **Control Panel Interface**: Manage redirects directly from the Statamic Control Panel

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

[](#installation)

You can install this addon via Composer:

```
composer require justbetter/statamic-detour
```

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

[](#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

[](#storage-driver)

The package supports two storage drivers:

#### File Driver (Default)

[](#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

[](#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

[](#performance-mode)

The package supports two modes for checking redirects:

#### Basic Mode (Default)

[](#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

[](#performance-mode-1)

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
```

### Auto create

[](#auto-create)

Redirects are automatically created whenever an entry's slug is changed. If you change the slug of a parent, this change will also be reflected in its children.

```
return [
    'auto_create' => true,
];
```

Or set via environment variable:

```
STATAMIC_DETOUR_AUTO_CREATE=true
```

### Query string defaults

[](#query-string-defaults)

Set global defaults for query string handling:

```
return [
    'query_string_default_handling' => 'strip_completely', // pass_through | strip_completely | strip_specific_keys
    'query_string_default_strip_keys' => 'gclid,fbclid',
];
```

You can also configure these from **Tools &gt; Detours &gt; Settings** in the Control Panel.

Usage
-----

[](#usage)

### Creating Redirects

[](#creating-redirects)

Navigate to **Tools &gt; Detours** in the Statamic Control Panel to manage your redirects.

#### Path 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
- **Query string handling**: Use global default, pass through, strip completely, or strip specific keys

#### Regex Redirects

[](#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
- **Query string handling**: Same options as path redirects

### Multi-Site Support

[](#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

[](#storage-considerations)

#### File Driver

[](#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 (&lt; 100 redirects)

#### Eloquent Driver

[](#eloquent-driver-1)

- Redirects are stored in the `detours` database table
- Better performance for large numbers of redirects
- Recommended for sites with 100+ redirects
- Supports faster lookups and queries

Development
-----------

[](#development)

When developing this addon, you'll need to build the Control Panel assets. **Node.js 22+** is required for the build process:

```
cd /path/to/statamic-detour
npm install
npm run build
```

For hot reloading during development, run `npm run dev` in a separate terminal.

Quality
-------

[](#quality)

To ensure the quality of this package, run the following command:

```
composer quality
```

This will execute three tasks:

1. Makes sure all tests are passed
2. Checks for any issues using static code analysis
3. Checks if the code is correctly formatted

Credits
-------

[](#credits)

- [Bob Wezelman](https://github.com/BobWez98)
- [Niek Boon](https://github.com/niekboon)
- [Kevin Meijer](https://github.com/kevinmeijer97)
- [All Contributors](../../contributors)

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

License
-------

[](#license)

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

[ ![JustBetter logo](./art/footer.svg)](https://justbetter.nl "JustBetter")

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance92

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~17 days

Recently: every ~24 days

Total

9

Last Release

15d ago

PHP version history (2 changes)0.0.1PHP ^8.3

0.4.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d00b3f55cd4ae8b8cfb001a644ed6c7a1127a956c24375bcfe16ce12bd89bed?d=identicon)[justbetter](/maintainers/justbetter)

---

Top Contributors

[![BobWez98](https://avatars.githubusercontent.com/u/23509926?v=4)](https://github.com/BobWez98 "BobWez98 (42 commits)")[![niekboon](https://avatars.githubusercontent.com/u/81699906?v=4)](https://github.com/niekboon "niekboon (35 commits)")[![kevinmeijer97](https://avatars.githubusercontent.com/u/9716909?v=4)](https://github.com/kevinmeijer97 "kevinmeijer97 (10 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/justbetter-statamic-detour/health.svg)

```
[![Health](https://phpackages.com/badges/justbetter-statamic-detour/health.svg)](https://phpackages.com/packages/justbetter-statamic-detour)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[statamic/seo-pro

68516.6k](/packages/statamic-seo-pro)[statamic/statamic

Statamic

829179.5k](/packages/statamic-statamic)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3416.6k](/packages/duncanmcclean-statamic-cargo)[binaryk/laravel-restify

Laravel REST API helpers

677415.0k](/packages/binaryk-laravel-restify)[lomkit/laravel-rest-api

A package to build quick and robust rest api for the Laravel framework.

59463.6k](/packages/lomkit-laravel-rest-api)

PHPackages © 2026

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