rekurzia/yii2-redirect

Simple Application class which tries to redirect to one of specified routes before handling request.

v1.0.0 2016-01-31 21:45 UTC

This package is not auto-updated.

Last update: 2024-04-19 08:30:17 UTC


README

Latest Stable Version License

Custom Application class which tries to redirect to one of specified routes before handling request.

It's useful if you moved website and forgot to set redirects properly and receiving many 404 Not Found errors.

Redirects go through standard \yii\helpers\Url::to() function, so they'll be 302 Found redirects.

Installation

Using Composer:

composer require rekurzia/yii2-redirect

Usage

Change your entry script (index.php) to use this class:

(new Rekurzia\redirect\Application($config))->run();

And add new routes through redirectRoutes option:

$config['redirectRoutes'] = [
    'some/route' => ['/site/index'],
    'another/route' => ['/site/index', 'page' => 'another'],
    'some/route?a=b&c=d' => ['/site/index', 'page' => 'abcd'],
    'outside/route' => 'http://www.yiiframework.com',
];

License

MIT. See LICENSE file.