PHPackages                             smart-cms/redirects - 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. smart-cms/redirects

ActiveLibrary

smart-cms/redirects
===================

This is my package redirects

1.x-dev(6mo ago)014MITPHPPHP ^8.2

Since Nov 19Pushed 6mo agoCompare

[ Source](https://github.com/s-cms/redirects)[ Packagist](https://packagist.org/packages/smart-cms/redirects)[ Docs](https://github.com/smart-cms/redirects)[ RSS](/packages/smart-cms-redirects/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (13)Versions (2)Used By (0)

This is my package redirects
============================

[](#this-is-my-package-redirects)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dc579ecbf17ae611ee3ab44fcbc2f957d38c194499fb9d8a536806a89f712767/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d6172742d636d732f7265646972656374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smart-cms/redirects)[![GitHub Tests Action Status](https://camo.githubusercontent.com/c296dab9ad7a9aaa3a31ccb5de9d9acb43ddc4bea3030dc3d11cc926d1b33b10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736d6172742d636d732f7265646972656374732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/smart-cms/redirects/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/bc60555c3682e7b85cec7a27050110dafc41ca1591e8d2be23caee163b8b93e5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736d6172742d636d732f7265646972656374732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/smart-cms/redirects/actions?query=workflow%3A%22Fix+PHP+code+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e5023fa4b774c807bb3d8da48da64dc7d8f8a62e5196b1972b80733c27c2186c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736d6172742d636d732f7265646972656374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/smart-cms/redirects)

A Laravel/Filament v4 package that provides comprehensive URL redirect management with automatic redirect handling, hit tracking, loop detection, and a powerful Filament admin panel for managing redirects.

Features
--------

[](#features)

- **Automatic Redirects**: Middleware automatically handles URL redirects (301 &amp; 302)
- **Hit Tracking**: Track redirect usage with hit count and last hit timestamp
- **Loop Detection**: Prevents creating circular redirect loops (A → B → A)
- **Caching**: Built-in caching support for optimal performance
- **Filament Resource**: Full-featured admin panel with inline create/edit modals
- **Import/Export**: Bulk operations via CSV import and export
- **Validation**: Prevents duplicate old\_urls and validates redirect chains

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

[](#installation)

You can install the package via composer:

```
composer require smart-cms/redirects
```

Full package install:

```
php artisan redirects:install
```

Or you can publish and run the migrations with:

```
php artisan vendor:publish --tag="redirects-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="redirects-config"
```

Usage
-----

[](#usage)

### Register the Filament Plugin

[](#register-the-filament-plugin)

Add the plugin to your Filament panel provider:

```
use SmartCms\Redirects\RedirectsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            RedirectsPlugin::make(),
            // Or with custom navigation group:
            RedirectsPlugin::make('Settings'),
        ]);
}
```

### Middleware

[](#middleware)

The redirect middleware is automatically registered to the `web` middleware group. When a user visits a URL that matches a redirect's `old_url`, they will be automatically redirected to the `new_url` with the specified status code (301 or 302).

### Creating Redirects Programmatically

[](#creating-redirects-programmatically)

```
use SmartCms\Redirects\Models\Redirect;

// Create a permanent redirect (301)
Redirect::create([
    'old_url' => '/old-page',
    'new_url' => '/new-page',
    'status_code' => 301,
]);

// Create a temporary redirect (302)
Redirect::create([
    'old_url' => '/temporary',
    'new_url' => '/new-location',
    'status_code' => 302,
]);
```

### Hit Tracking

[](#hit-tracking)

The package automatically tracks how many times each redirect is used:

```
$redirect = Redirect::find(1);

echo $redirect->hit_count;      // Number of times this redirect was used
echo $redirect->last_hit_at;    // Carbon instance of last hit

// Find popular redirects
$popular = Redirect::where('hit_count', '>', 100)->get();

// Find recently used redirects
$recent = Redirect::where('last_hit_at', '>', now()->subDays(7))->get();

// Find unused redirects
$unused = Redirect::where('hit_count', 0)
    ->whereNull('last_hit_at')
    ->get();
```

### Loop Detection

[](#loop-detection)

The package prevents creating circular redirect loops:

```
// This will be prevented:
Redirect::create(['old_url' => '/page', 'new_url' => '/page']); // Self-loop

// If you have: /a → /b
// This will be prevented: /b → /a (creates circular loop)

// The validation also detects complex loops:
// /a → /b → /c → /a (prevents closing the loop)
```

### Import/Export

[](#importexport)

Use the Filament admin panel to:

- **Export All**: Export all redirects to CSV via the header "Export CSV" button
- **Export Selected**: Select specific redirects and use the bulk action "Export Selected"
- **Import CSV**: Click "Import CSV" and upload a CSV file with columns: `old_url`, `new_url`, `status_code`

CSV Format:

```
old_url,new_url,status_code,hit_count
/old-page,/new-page,301,0
/temporary,/destination,302,0
```

### Caching

[](#caching)

Redirects are cached for performance. The cache is automatically cleared when:

- A redirect is created
- A redirect is updated
- A redirect is deleted

To manually clear the cache:

```
Redirect::clearCache();
```

To disable caching:

```
// In config/redirects.php
'cache' => [
    'enabled' => false,
],
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [maxboyko](https://github.com/SmartCms)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance69

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Unknown

Total

1

Last Release

180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/91ce18980be3db08a832b33c12273dcd9687bb699fcaf85c850ac3026112062f?d=identicon)[Smart-CMS](/maintainers/Smart-CMS)

---

Top Contributors

[![MaxBoiko21](https://avatars.githubusercontent.com/u/92517114?v=4)](https://github.com/MaxBoiko21 "MaxBoiko21 (4 commits)")

---

Tags

laravelfilamentphpredirectsSmartCms

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/smart-cms-redirects/health.svg)

```
[![Health](https://phpackages.com/badges/smart-cms-redirects/health.svg)](https://phpackages.com/packages/smart-cms-redirects)
```

###  Alternatives

[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

124139.3k2](/packages/dotswan-filament-map-picker)[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

15828.6k](/packages/relaticle-custom-fields)[jibaymcs/filament-tour

Bring the power of DriverJs to your Filament panels and start a tour !

12247.8k](/packages/jibaymcs-filament-tour)[guava/filament-modal-relation-managers

Allows you to embed relation managers inside filament modals.

7565.0k4](/packages/guava-filament-modal-relation-managers)[marcelweidum/filament-passkeys

Use passkeys in your filamentphp app

5925.8k](/packages/marcelweidum-filament-passkeys)[defstudio/filament-searchable-input

A searchable autocomplete input for Filament forms

3212.4k](/packages/defstudio-filament-searchable-input)

PHPackages © 2026

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