PHPackages                             samsonasik/expressive-redirect-handler - 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. samsonasik/expressive-redirect-handler

ActiveLibrary

samsonasik/expressive-redirect-handler
======================================

Expressive middleware for URL Redirect handling

2.0.0(6y ago)9501MITPHPPHP ^7.1

Since Oct 25Pushed 6y ago4 watchersCompare

[ Source](https://github.com/samsonasik/ExpressiveRedirectHandler)[ Packagist](https://packagist.org/packages/samsonasik/expressive-redirect-handler)[ Docs](https://github.com/samsonasik/ExpressiveRedirectHandler)[ RSS](/packages/samsonasik-expressive-redirect-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (30)Used By (0)

ExpressiveRedirectHandler
=========================

[](#expressiveredirecthandler)

[![PHP version](https://camo.githubusercontent.com/4613234cef13eaa03cbf9321b0861a5300528c7c5f92b7a00cff775de7503642/68747470733a2f2f62616467652e667572792e696f2f70682f73616d736f6e6173696b253246657870726573736976652d72656469726563742d68616e646c65722e737667)](https://badge.fury.io/ph/samsonasik%2Fexpressive-redirect-handler)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/441f80d9da5246009445fceae2e7038cebcfe35e3861257f63664d74f28d212c/68747470733a2f2f7472617669732d63692e6f72672f73616d736f6e6173696b2f45787072657373697665526564697265637448616e646c65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/samsonasik/ExpressiveRedirectHandler)[![Coverage Status](https://camo.githubusercontent.com/0e3720df9e1b23128325a8a267c40330b2b1b53ce0fc6daf745298f3a8de3da6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f73616d736f6e6173696b2f45787072657373697665526564697265637448616e646c65722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/samsonasik/ExpressiveRedirectHandler)[![Downloads](https://camo.githubusercontent.com/256fe81f2cacbf029c91c8f2f4cc8fd727b682dacd9c01c11cfff96e7c704dee/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6173696b2f657870726573736976652d72656469726563742d68616e646c65722f646f776e6c6f616473)](https://packagist.org/packages/samsonasik/expressive-redirect-handler)

> This is README for version ^2.0 which only support Mezzio version 3 with php ^7.1.

> For version ^1.0, , you can read at [version 1.\* readme](https://github.com/samsonasik/ExpressiveRedirectHandler/tree/1.x.x) which support ZF Expressive version 3 with php ^7.1.

> For version 0.\*, you can read at [version 0.\* readme](https://github.com/samsonasik/ExpressiveRedirectHandler/tree/0.x.x) which still ZF Expressive version 1 and 2 with php ^5.6|^7.0 support.

*ExpressiveRedirectHandler* is a package that contains [Mezzio](https://github.com/mezzio/mezzio) middleware for handling redirect that fit with [mezzio-skeleton](https://github.com/mezzio/mezzio-skeleton) for following conditions:

1. When the given url to `RedirectResponse` is not registered in routing config

---

For example, we use `RedirectResponse` instance in our Middleware:

```
use Laminas\Diactoros\Response\RedirectResponse;
// ...
$redirect = '/foo'; // may be a variable from GET
return new RedirectResponse($redirect);
```

if the passed `$redirect` as url is a valid and registered in the routes, it uses default `RedirectResponse` implementation, otherwise, it will redirect to default `default_url` registered in `config/autoload/expressive-redirect-handler.local.php`:

For example, we define:

```
