afea / filament-redirect
Redirect module for the Afea Filament CMS package ecosystem: 301/302 URL redirects with bulk CSV import and hit tracking.
v0.1.0
2026-04-21 10:48 UTC
Requires
- php: ^8.4
- afea/filament-cms-core: @dev
- filament/filament: ^4.0
- illuminate/contracts: ^12.0
- illuminate/database: ^12.0
- illuminate/support: ^12.0
- laravel/prompts: ^0.3
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
README
Redirect module for the Afea Filament CMS package ecosystem.
Ships:
Redirectmodel — source/target URL, 301/302/303/307/308, hit trackingRedirectStatusCodeenum with HasLabel + HasColorHandleRedirectsmiddleware — intercepts GET/HEAD requests and serves 301/302 responses from the database- Filament v4
RedirectResourcewith CSV bulk import RedirectPluginfor panel registrationafea:install:redirectinstaller
Installation
composer require afea/filament-redirect php artisan afea:install:redirect
Register in AdminPanelProvider:
->plugin(\Afea\Cms\Redirect\Filament\RedirectPlugin::make())
Register the middleware in bootstrap/app.php:
$middleware->web(append: [ \Afea\Cms\Redirect\Http\Middleware\HandleRedirects::class, ]);
CSV import format
source_url,target_url,status_code,is_active /old-page,https://example.com/new-page,301,1 /legacy/blog/*,https://example.com/blog,302,1
Aliases: from/source, to/target, code/status, active. status_code defaults to 301 and is_active to 1. Duplicate source_url rows update the existing rule in place.
Three common scenarios
1. Disable hit tracking on high-traffic sites
Set AFEA_REDIRECT_TRACK_HITS=false. Saves one write per matched request.
2. Seed redirects from a migration
use Afea\Cms\Redirect\Models\Redirect; Redirect::query()->insert([ ['source_url' => '/eski-blog', 'target_url' => '/blog', 'status_code' => 301, 'is_active' => true, 'hit_count' => 0, 'created_at' => now(), 'updated_at' => now()], ]);
3. Override the model to add a scope
class Redirect extends \Afea\Cms\Redirect\Models\Redirect { public function scopeStale(Builder $q): Builder { return $q->where('last_used_at', '<', now()->subMonths(6)); } }
'models' => ['redirect' => \App\Models\Redirect::class],