A redirect repository for PSR-15 middleware packages

v1.1.0 2018-08-04 10:41 UTC


Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

Middleware to redirect old urls to new urls SEO friendly.



This package is installable and autoloadable via Composer as middlewares/redirect.

composer require middlewares/redirect


$dispatcher = new Dispatcher([
	(new Middlewares\Redirect(['/old-url' => '/new-url']))
		->method(['GET', 'POST'])

$response = $dispatcher->dispatch(new ServerRequest());


__construct(array|ArrayAccess $redirects)

The list of urls that must be redirected. It can be an array or an object implementing the ArrayAccess interface.

permanent(bool $permanent)

Use temporary or permanent redirection HTTP status code for the response. (Default: true.)

query(bool $query)

Take the query part of the URI into account when matching redirects. (Default: true.)

method(array $methods)

Array with allow HTTP request methods. (Default: ['GET'].)

responseFactory(Psr\Http\Message\ResponseFactoryInterface $responseFactory)

A PSR-17 factory to create redirect responses.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

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