PHPackages                             tofandel/laravel-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. [HTTP &amp; Networking](/categories/http)
4. /
5. tofandel/laravel-redirects

ActiveLibrary[HTTP &amp; Networking](/categories/http)

tofandel/laravel-redirects
==========================

Nested URLs redirect logic for Laravel

v4.3.0(9mo ago)37.5k2MITPHPPHP ^7.3|^8.0

Since Jun 3Pushed 9mo agoCompare

[ Source](https://github.com/Tofandel/laravel-redirects)[ Packagist](https://packagist.org/packages/tofandel/laravel-redirects)[ RSS](/packages/tofandel-laravel-redirects/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (5)Versions (16)Used By (0)

### Nested redirects for Laravel

[](#nested-redirects-for-laravel)

[![Build Status](https://camo.githubusercontent.com/6a94cfbb024a8098a60fbda53028de08dc16d295c56521f04af8db0c8bde150d/68747470733a2f2f7472617669732d63692e6f72672f546f66616e64656c2f6c61726176656c2d7265646972656374732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Tofandel/laravel-redirects)[![StyleCI](https://camo.githubusercontent.com/13692b9bd1f338e85179b9786b04da91dae61e9f1ceb7bc8d5932f29abfbb6aa/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3434373537303935352f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/447570955?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6f9e046a3573af67dbf23438f047f968e0c0886ff953cc454e44e91c09784d94/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f546f66616e64656c2f6c61726176656c2d7265646972656374732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Tofandel/laravel-redirects/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/4d66a3e157457e504ebdab00f29a541b535d534b00d5f9450b33b45ff684f7c1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f546f66616e64656c2f6c61726176656c2d7265646972656374732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Tofandel/laravel-redirects/?branch=master)

- [Overview](#overview)
- [Installation](#installation)
- [Usage](#usage)

### Overview

[](#overview)

This package allows you to create simple or multiple nested redirects for your Laravel applications.

This package can be useful from an SEO perspective, when in your application, you have URLs that have the potential of being modified.

**Example of the dynamic redirecting logic:**

- Let's assume you have an URL called `/original`
- You create a redirect from `/original` to `/modified`

    > Accessing `/original` will redirect to `/modified`
- You create another redirect from `/modified` to `/modified-again`

    > Accessing `/modified` will redirect to `/modified-again` AND
    > Accessoing `/original` will redirect to `/modified-again`
- You create another redirect from `/modified-again` to `/modified-yet-again`

    > Accessing `/modified-again` will redirect to `/modified-yet-again` AND
    > Accessing `/modified` will redirect to `/modified-yet-again` AND
    > Accessing `/original` will redirect to `/modified-yet-again`
- You create another redirect from `modified-yet-again` to `/original`

    > Accessing `/modified-yet-again` will redirect to `/original` AND
    > Accessing `/modified-again` will redirect to `/original` AND
    > Accessing `/modified` will redirect to `/original`

### Installation

[](#installation)

Install the package via Composer:

```
composer require Tofandel/laravel-redirects

```

Publish the config file with:

```
php artisan vendor:publish --provider="Tofandel\Redirects\ServiceProvider" --tag="config"

```

Publish the migration file with:

```
php artisan vendor:publish --provider="Tofandel\Redirects\ServiceProvider" --tag="migrations"

```

After the migration has been published you can create the `redirects` table by running:

```
php artisan migrate

```

### Usage

[](#usage)

##### Add the middleware

[](#add-the-middleware)

In order for the redirecting functionality to actually happen, you need to add the `Tofandel\Redirects\Middleware\RedirectRequests` middleware.

Go to `App\Http\Kernel` and add the `Tofandel\Redirects\Middleware\RedirectRequests` middleware in your `$middlewareGroups` groups of choice.

```
/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        ...
        \Tofandel\Redirects\Middleware\RedirectRequests::class,
```

##### Creating redirects

[](#creating-redirects)

You should never use the `Tofandel\Redirects\Models\Redirect` directly, as this is the default concrete implementation for the `Tofandel\Redirects\Contracts\RedirectModelContract`.

Using the `Tofandel\Redirects\Models\Redirect` model class directly will prevent you from being able to extend the model's capabilities.

You can create redirects that will be stored inside the `redirects` table like this:

```
app('redirect.model')->create([
    'old_url' => '/your-old-url',
    'new_url' => '/your-new-url',
    'status' => 301
]);
```

To see how you can extend the `Tofandel\Redirects\Models\Redirect` model's capabilities, please read the comments from `/config/redirects.php -> redirect_model`

### Credits

[](#credits)

- [Andrei Badea](https://github.com/zbiller)
- [All Contributors](../../contributors)

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

### License

[](#license)

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

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

### Contributing

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance56

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 59.4% 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 ~191 days

Recently: every ~328 days

Total

13

Last Release

289d ago

Major Versions

1.0.0 → 2.0.02019-11-19

2.0.0 → 3.0.02020-06-09

3.0.0 → 4.0.02022-01-13

PHP version history (4 changes)1.0.0PHP ^7.1.3

2.0.0PHP ^7.2

3.0.0PHP ^7.2.5

4.0.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6115458?v=4)[Adrien Foulon](/maintainers/Tofandel)[@Tofandel](https://github.com/Tofandel)

---

Top Contributors

[![zbiller](https://avatars.githubusercontent.com/u/2579306?v=4)](https://github.com/zbiller "zbiller (38 commits)")[![Tofandel](https://avatars.githubusercontent.com/u/6115458?v=4)](https://github.com/Tofandel "Tofandel (18 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![pideee](https://avatars.githubusercontent.com/u/23198327?v=4)](https://github.com/pideee "pideee (1 commits)")[![blaiselcq](https://avatars.githubusercontent.com/u/70012135?v=4)](https://github.com/blaiselcq "blaiselcq (1 commits)")[![joshmurrayeu](https://avatars.githubusercontent.com/u/13717924?v=4)](https://github.com/joshmurrayeu "joshmurrayeu (1 commits)")[![bacanu](https://avatars.githubusercontent.com/u/1362133?v=4)](https://github.com/bacanu "bacanu (1 commits)")

---

Tags

urlsluglaravelredirectseo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tofandel-laravel-redirects/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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