PHPackages                             1970mr/laravel-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. [Testing &amp; Quality](/categories/testing)
4. /
5. 1970mr/laravel-redirector

ActiveLibrary[Testing &amp; Quality](/categories/testing)

1970mr/laravel-redirector
=========================

A Laravel package for managing URL redirects easily and efficiently.

v1.3.1(1y ago)115MITPHPPHP ^8.2

Since Aug 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/1970Mr/laravel-redirector)[ Packagist](https://packagist.org/packages/1970mr/laravel-redirector)[ Docs](https://github.com/1970Mr/laravel-redirector)[ RSS](/packages/1970mr-laravel-redirector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (7)Used By (0)

Laravel Redirector
==================

[](#laravel-redirector)

A Laravel package for managing URL redirects easily and efficiently.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Middleware](#middleware)
    - [Artisan Commands](#artisan-commands)
    - [Controller and Views](#controller-and-views)
    - [Custom Implementation](#custom-implementation)
- [Caching](#caching)
- [Testing](#testing)
- [License](#license)

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

[](#installation)

You can install the package via Composer:

```
composer require 1970mr/laravel-redirector
```

Next, you need to publish the migration and the config file:

```
php artisan vendor:publish --provider="Mr1970\LaravelRedirector\RedirectorServiceProvider"
```

Run the migrations to create the necessary database table:

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

The package provides a configuration file where you can manage various settings, including caching methods and TTL (Time-To-Live). These settings allow you to optimize the performance and scalability of your redirects. Refer to the `config/redirector.php` file for more details.

Usage
-----

[](#usage)

### Middleware

[](#middleware)

To use the redirect middleware, you can apply it to specific routes, groups of routes, or add it globally to the HTTP kernel middleware stack.

#### Specific Routes

[](#specific-routes)

```
use Mr1970\LaravelRedirector\Middlewares\HandleRedirects;

Route::middleware([HandleRedirects::class])->group(function () {
    // Your routes here
});
```

#### Global Middleware

[](#global-middleware)

In Laravel 11, you can add middleware globally in your `bootstrap/app.php` file:

```
->withMiddleware(function (Middleware $middleware) {
     $middleware->append(\Mr1970\LaravelRedirector\Middlewares\HandleRedirects::class);
})
```

#### Alias Middleware

[](#alias-middleware)

You can use the middleware by its alias or by the class name in your routes:

```
// Using alias
Route::middleware(['redirector'])->group(function () {
    // Your routes here
});

// Using class name
Route::middleware([\Mr1970\LaravelRedirector\Middlewares\HandleRedirects::class])->group(function () {
    // Your routes here
});
```

### Artisan Commands

[](#artisan-commands)

The package provides several Artisan commands to manage redirects:

#### Create Redirect

[](#create-redirect)

To create a redirect, you can use the `redirect:create` Artisan command. This command allows you to specify the source URL, destination URL, status code, and whether the redirect is active.

```
php artisan redirect:create {source_url} {destination_url} {status_code=301} {is_active=1}
```

##### Examples

[](#examples)

1. Redirect from `/old-page` to `/new-page` with a 301 status code and set it as active:

    ```
    php artisan redirect:create /old-page /new-page 301 1
    ```
2. Redirect from `/specific-page` to `https://google.com` with a 301 status code and set it as active:

    ```
    php artisan redirect:create /specific-page https://google.com 301 1
    ```

#### Update Redirect

[](#update-redirect)

To update an existing redirect, you can use the `redirect:update` Artisan command:

```
php artisan redirect:update {source_url} {destination_url} {status_code=301} {is_active=1}
```

##### Example

[](#example)

Update the redirect from `/old-page` to `/new-destination` with a 302 status code and set it as active:

```
php artisan redirect:update /old-page /new-destination 302 1
```

#### Delete Redirect

[](#delete-redirect)

To delete a redirect, use the `redirect:delete` Artisan command:

```
php artisan redirect:delete {source_url}
```

##### Example

[](#example-1)

Delete the redirect from `/old-page`:

```
php artisan redirect:delete /old-page
```

#### List Redirects

[](#list-redirects)

To list all configured redirects, use the `redirect:list` Artisan command:

```
php artisan redirect:list
```

### Controller and Views

[](#controller-and-views)

You can also set up a more customizable CRUD interface for redirects using controllers, requests, routes, and views. The package provides a command to scaffold these components:

```
php artisan redirector:install
```

This command will install the necessary controllers, requests, routes, and views for managing redirects through a web interface.

### Custom Implementation

[](#custom-implementation)

Additionally, you can use the Redirect model directly to create, update, or delete redirects within your application code as needed. This approach allows for complete customization of how and where redirects are managed.

Caching
-------

[](#caching)

The package supports two caching methods:

- **Full List**: All active redirects are cached as a single collection. This method is efficient for a small number of redirects but may become inefficient as the number of redirects grows. Any create, update, or delete operation will reset the entire list cache.
- **Single**: Each redirect is cached individually. This method scales better with a large number of redirects but may result in more cache operations. Only the specific cached item is reset during create, update, or delete operations.

You can configure the caching method and TTL in the `config/redirector.php` file to suit your application's needs.

Testing
-------

[](#testing)

To run the tests for the package, use the following command:

```
composer test
```

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~1 days

Total

6

Last Release

640d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5645c2b4e0cc01dae13886af2a97d1eba92f6cdab127b932a7d042a96a31d5d6?d=identicon)[1970Mr](/maintainers/1970Mr)

---

Top Contributors

[![1970Mr](https://avatars.githubusercontent.com/u/95953273?v=4)](https://github.com/1970Mr "1970Mr (26 commits)")

---

Tags

laravellaravel-packagelaravel-redirectormanagementpackageredirectredirectionredirectorredirectsredirects-managementrouteroutingtestingurlurllaravelpackageroutingmanagementrouteredirectredirectsredirector1970Mrlaravel-redirectorMr1970

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/1970mr-laravel-redirector/health.svg)

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

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[nunomaduro/laravel-mojito

A lightweight package for testing Laravel views.

368435.5k11](/packages/nunomaduro-laravel-mojito)[illuminatech/url-trailing-slash

Allows enforcing URL routes with or without trailing slash

50216.9k](/packages/illuminatech-url-trailing-slash)[sirodiaz/laravel-redirection

Laravel package that allows storing in database (or other sources) urls to redirect for SEO purposes

6316.0k](/packages/sirodiaz-laravel-redirection)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

1484.6k3](/packages/calebdw-larastan)

PHPackages © 2026

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