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
Requires
- yiisoft/yii2: ~2.0
This package is not auto-updated.
Last update: 2024-11-15 11:20:02 UTC
README
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.