pecotamic / redirect
Requires
- php: ^8.2
- statamic/cms: ^5.0|^6.0
Requires (Dev)
- laravel/pint: ^1.31
- mockery/mockery: ^1.6
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^13
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Adds 301 and 302 redirects, and 403, 404 and 410 aborts, to your Statamic web site. Rules are managed directly from the Statamic control panel — no code or config changes needed.
How to Install
You can search for this addon in the Tools > Addons section of the Statamic control panel and click install, or run the following command from your project root:
composer require pecotamic/redirect
The package requires PHP 8.2+. It will auto register.
Usage
Installing the addon adds a Redirects entry of its own to the control panel navigation (it's a Collection under the hood, but kept out of the general Collections list to avoid mixing it in with your actual content), with one entry per redirect rule — so the list stays fast and searchable even with a large number of redirects. Its field labels follow the control panel's active language (German and English are built in). Each rule has:
- Request URI: the incoming path to match, e.g.
/old-page - Match type:
Exactmatches the path exactly,Starts withmatches any path starting with it - Response: the HTTP status code to respond with —
301(Moved Permanently),302(Moved Temporarily),403(Forbidden),404(Not Found) or410(Gone) - Target: the redirect destination, required for
301/302. Accepts a relative path (e.g./new-page) or an absolutehttp(s)://URL
A redirect can be unpublished (via the entry's regular publish/unpublish control) to disable it without deleting it.
Upgrading from 1.x
Versions up to 1.1.1 stored redirects in a single "Weiterleitungen" global set instead of a collection. After upgrading, run:
php artisan pecotamic:redirects:migrate
This copies existing redirects into the new collection (an unpublished/disabled rule stays unpublished), then deletes the old global set. It's safe to run more than once — existing entries are skipped, not duplicated.