afea/filament-redirect

Redirect module for the Afea Filament CMS package ecosystem: 301/302 URL redirects with bulk CSV import and hit tracking.

Maintainers

Package info

github.com/AfeaSoftware/filament-redirect

pkg:composer/afea/filament-redirect

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-04-21 10:48 UTC

This package is auto-updated.

Last update: 2026-04-21 11:57:35 UTC


README

Redirect module for the Afea Filament CMS package ecosystem.

Ships:

  • Redirect model — source/target URL, 301/302/303/307/308, hit tracking
  • RedirectStatusCode enum with HasLabel + HasColor
  • HandleRedirects middleware — intercepts GET/HEAD requests and serves 301/302 responses from the database
  • Filament v4 RedirectResource with CSV bulk import
  • RedirectPlugin for panel registration
  • afea:install:redirect installer

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],