Skip to content

rekurzia/yii2-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii2 Redirect

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages