PHPackages                             movor/laravel-db-redirector - 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. [Database &amp; ORM](/categories/database)
4. /
5. movor/laravel-db-redirector

ActiveLibrary[Database &amp; ORM](/categories/database)

movor/laravel-db-redirector
===========================

Manage Laravel HTTP redirections using database

v0.3.1(7y ago)275MITPHP

Since Aug 5Pushed 7y ago1 watchersCompare

[ Source](https://github.com/movor/laravel-db-redirector)[ Packagist](https://packagist.org/packages/movor/laravel-db-redirector)[ RSS](/packages/movor-laravel-db-redirector/feed)WikiDiscussions master Synced yesterday

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

Laravel DB redirector
=====================

[](#laravel-db-redirector)

[![Build](https://camo.githubusercontent.com/76c28dccd06ad1dcca7e9664700cbd0fb01e06fa70ed7aa6731964796c212c04/68747470733a2f2f7472617669732d63692e6f72672f6d6f766f722f6c61726176656c2d64622d72656469726563746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/movor/laravel-db-redirector)[![Downloads](https://camo.githubusercontent.com/c14dbf60131b585d258fd0d004b9f294cacf86dcbf277883bbfe5efbe8439018/68747470733a2f2f706f7365722e707567782e6f72672f6d6f766f722f6c61726176656c2d64622d72656469726563746f722f646f776e6c6f616473)](https://packagist.org/packages/movor/laravel-db-redirector)[![Stable](https://camo.githubusercontent.com/58c5ddd76cd5def8da163479f3a7b918c1d55a0bdf0eac1f74547bce22e6e966/68747470733a2f2f706f7365722e707567782e6f72672f6d6f766f722f6c61726176656c2d64622d72656469726563746f722f762f737461626c65)](https://packagist.org/packages/movor/laravel-db-redirector)[![License](https://camo.githubusercontent.com/e76312daf72cf1a005b240a09027ce2a2eeef121df80d37eee86eb93acda0a09/68747470733a2f2f706f7365722e707567782e6f72672f6d6f766f722f6c61726176656c2d64622d72656469726563746f722f6c6963656e7365)](https://packagist.org/packages/movor/laravel-db-redirector)

### Manage HTTP redirections in Laravel using database

[](#manage-http-redirections-in-laravel-using-database)

Manage redirects using database rules. Rules are intended to be very similar to Laravel default routes, so syntax is pretty easy to comprehend.

---

❗❗❗ **MOVING GIT REPOSITORY**❗❗❗

This package **repo and maintenance will continue on**:

[**vkovic/laravel-db-redirector**](https://github.com/vkovic/laravel-db-redirector).

🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚 🚚

---

Compatibility
-------------

[](#compatibility)

The package is compatible with Laravel versions `>= 5.1`

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

[](#installation)

Install the package via composer:

```
composer require movor/laravel-db-redirector
```

The package needs to be registered in service providers:

```
// File: config/app.php

// ...

/*
 * Package Service Providers...
 */

// ...

Movor\LaravelDbRedirector\Providers\DbRedirectorServiceProvider::class,
```

Database redirector middleware needs to be added to middleware array:

```
// File: app/Http/Kernel.php

// ...

protected $middleware = [
    // ...
    \Movor\LaravelDbRedirector\Http\Middleware\DbRedirectorMiddleware::class
];
```

Run migrations to create table which will store redirect rules:

```
php artisan migrate
```

Usage: Simple Examples
----------------------

[](#usage-simple-examples)

Creating a redirect is easy. You just have to add db record via provided RedirectRule model. Default status code for redirections will be 301 (Moved Permanently).

```
use Movor\LaravelDbRedirector\Models\RedirectRule;

// ...

RedirectRule::create([
    'origin' => '/one/two',
    'destination' => '/three'
]);
```

You can also specify another redirection status code:

```
RedirectRule::create([
    'origin' => '/one/two',
    'destination' => '/three',
    'status_code' => 307 // Temporary Redirect
]);
```

You may use route parameters just like in native Laravel routes, they'll be passed down the road - from origin to destination:

```
RedirectRule::create([
    'origin' => '/one/{param}',
    'destination' => '/two/{param}'
]);

// If we visit: "/one/foo" we will end up at "two/foo"
```

Optional parameters can also be used:

```
RedirectRule::create([
    'origin' => '/one/{param1?}/{param2?}',
    'destination' => '/four/{param1}/{param2}'
]);

// If we visit: "/one" we'll end up at "/four
// If we visit: "/one/two" we'll end up at "/four/two"
// If we visit: "/one/two/three" we'll end up at "/four/two/three"
```

Chained redirects will also work:

```
RedirectRule::create([
    'origin' => '/one',
    'destination' => '/two'
]);

RedirectRule::create([
    'origin' => '/two',
    'destination' => '/three'
]);

RedirectRule::create([
    'origin' => '/three',
    'destination' => '/four'
]);

// If we visit: "/one" we'll end up at "/four"
```

We also can delete the whole chain at once (3 previous redirect records in this example):

```
RedirectRule::deleteChainedRecursively('/four');
```

Sometimes it's possible that you'll have more than one redirection with the same destination. So it's smart to surround code with try catch block, because exception will be raised in this case:

```
RedirectRule::create(['origin' => '/one/two', 'destination' => '/three/four']);
RedirectRule::create(['origin' => '/three/four', 'destination' => '/five/six']);

// One more with same destination ("/five/six") as the previous one.
RedirectRule::create(['origin' => '/ten/eleven', 'destination' => '/five/six']);

try {
    RedirectRule::deleteChainedRecursively('five/six');
} catch (\Exception $e) {
    // ... handle exception
}
```

Usage: Advanced
---------------

[](#usage-advanced)

What about order of rules execution when given url corresponds to multiple rules. Let's find out in this simple example:

```
RedirectRule::create(['origin' => '/one/{param}/three', 'destination' => '/four']);
RedirectRule::create(['origin' => '/{param}/two/three', 'destination' => '/five']);

// If we visit: "/one/two/three" it corresponds to both of rules above,
// so, where should we end up: "/four" or "/five" ?
// ...
// It does not have anything to do with rule order in our rules table!
```

To solve this problem, we need to agree on simple (and logical) rule prioritizing:

**Priority 1:**Rules without named parameters have top priority:

**Priority 2:**If rule origin have named parameters, those with less named parameters will have higher priority

**Priority 3:**If rule origin have same number of named parameters, those where named parameters are nearer the end of the rule string will have priority

So lets examine our previous case, we have:

- "/one/{param}/three" =&gt; "/four"
- "/{param}/two/three" =&gt; "/five"

In this case both rules have the same number of named params, but in the first rule "{param}" is nearer the end of the rule, so it will have priority and we'll end up at "/four".

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Every ~16 days

Recently: every ~28 days

Total

8

Last Release

2768d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4613605?v=4)[Vladimir Ković](/maintainers/vkovic)[@vkovic](https://github.com/vkovic)

---

Top Contributors

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

---

Tags

databaselaravelpackageredirectrouterroutinglaraveldatabaseredirect

### Embed Badge

![Health badge](/badges/movor-laravel-db-redirector/health.svg)

```
[![Health](https://phpackages.com/badges/movor-laravel-db-redirector/health.svg)](https://phpackages.com/packages/movor-laravel-db-redirector)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11222.5M33](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

854.1k](/packages/waad-laravel-model-metadata)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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