PHPackages                             hmones/laravel-redirect - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. hmones/laravel-redirect

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

hmones/laravel-redirect
=======================

Redirects users automatically after login to the previous protected route they were trying to access

v1.1.0(4y ago)5132MITPHP

Since Dec 10Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hmones/laravel-redirect)[ Packagist](https://packagist.org/packages/hmones/laravel-redirect)[ Docs](https://github.com/hmones/laravel-redirect)[ RSS](/packages/hmones-laravel-redirect/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Laravel Redirect
================

[](#laravel-redirect)

[![Build Status](https://github.com/hmones/laravel-redirect/actions/workflows/build.yml/badge.svg)](https://github.com/hmones/laravel-redirect/actions)[![Style CI](https://camo.githubusercontent.com/ae6f0d438afce5a23eb7ba178e4fda6f4eb3c9d85b47ba79983dd9394933a8d3/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3433353439323432372f736869656c64)](https://github.styleci.io/repos/435492427)[![Total Downloads](https://camo.githubusercontent.com/460e114deb0bd8eee0e31cc3fecdd3ae0a83529b60d854a636f60d49a654bb32/687474703a2f2f706f7365722e707567782e6f72672f686d6f6e65732f6c61726176656c2d72656469726563742f646f776e6c6f616473)](https://packagist.org/packages/hmones/laravel-redirect)[![Latest Stable Version](https://camo.githubusercontent.com/9a6e85f4d3abf9f1055fea9c4d219ef0af433bc7ae9b8fb7f3ed36b6afa6c378/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f686d6f6e65732f6c61726176656c2d7265646972656374)](https://packagist.org/packages/hmones/laravel-redirect)[![License](https://camo.githubusercontent.com/8c5205f4de0a5e46d877000f2a1ba2cdcb2ee925aec0d5fe6a4adafa42fd743e/687474703a2f2f706f7365722e707567782e6f72672f686d6f6e65732f6c61726176656c2d72656469726563742f6c6963656e7365)](https://packagist.org/packages/hmones/laravel-redirect)

This package is a configurable add-on to your laravel application that allows you to do the following:

- Redirect users back to the protected (needs-authorization) page they wanted to visit right after they log-in instead of the default page.
- Redirect users to a particular destination inside or outside your application by providing that link in a url parameter when logging in or on any of your application pages (e.g. ).
- Configure the redirect parameter, disable it, make it only accept certain regex or change the name of that parameter
- Configure the middleware group used for authentication in case you are not using laravel defaults or want to use the redirect for another middleware group.

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

[](#installation)

Via Composer

```
composer require hmones/laravel-redirect
```

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

[](#configuration)

To publish the package configuration

```
php artisan vendor:publish --tag=laravel-redirect-config
```

The configuration file contains the following parameters:

- `web_middleware`: the name of your application's web middleware
    - Env variable: `WEB_MIDDLEWARE`
    - Default value: `web`
- `parameter.enabled` whether you would like to enable parameter redirect on your application, once enabled a user can be redirected for example after login given that their login url was as in this example: `https://mydomain.com/login?redirect=https://another-url.com`
    - Env variable: `REDIRECT_PARAMETER_ENABLED`
    - Default value: `true`
- `parameter.name` if parameter redirect is enabled, you can customize the query parameter used to capture the redirect link
    - Env variable: `REDIRECT_PARAMETER`
    - Default value: `redirect`
- `parameter.regex` if parameter redirect is enabled, you can add a regex to check the redirect query parameter e.g. `/^.*mydomain\.com$/`
    - Env variable: `REDIRECT_REGEX`
    - Default value: `null`
- `routes.login` the name of the login route used by your application
    - Env variable: `LOGIN_ROUTE_NAME`
    - Default value: `login`
- `routes.logout` the name of the logout route used by your application
    - Env variable: `LOGOUT_ROUTE_NAME`
    - Default value: `logout`
- `routes.default` the name of the route that the user is redirected to by default after login
    - Env variable: `DEFAULT_ROUTE_NAME`
    - Default value: `home`

Usage
-----

[](#usage)

- Install the package
- Adjust the configuration parameters in your `.env` file or publish the package configuration file to modify it.
- Add the package service provider at the end of the providers array in your app configuration file `config\app.php`

```
    'providers' => [
        ...
        Hmones\LaravelRedirect\LaravelRedirectServiceProvider::class
    ],
```

Change log
----------

[](#change-log)

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

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](CONTRIBUTING.md) for details and a todolist.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Haytham Mones](https://github.com/hmones)

License
-------

[](#license)

Please see the [license file](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

1463d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7da4fc759399b2b0a29e8a7266234caeb6d764fc9b34869ff0d2bb7c812464d1?d=identicon)[haythammones](/maintainers/haythammones)

---

Top Contributors

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

---

Tags

laravelLaravelRedirect

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hmones-laravel-redirect/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42442.0M544](/packages/socialiteproviders-manager)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[casbin/laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.

324339.9k4](/packages/casbin-laravel-authz)

PHPackages © 2026

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