PHP code example of mrssoft / yii2-url-redirect

1. Go to this page and download the library: Download mrssoft/yii2-url-redirect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrssoft / yii2-url-redirect example snippets


    'components' => [
        ...
        'redirect' => [
            'class' => 'mrssoft\redirect\UrlRedirect',
            'tableName' => '{{%redirect}}', // Table name
            'db' => 'db', // DB connection component
            'code' => 302, // Redirect status code
        ],
        'response' => [
            'as urlRedirect' => [
                'class' => 'mrssoft\redirect\UrlBehavior',
                'redirect' => 'redirect' // UrlRedirect component
            ]
        ],
        ...
    ]

    Yii::$app->redirect->add('/old/url/', '/new/url');

    Yii::$app->redirect->clear('-3 month');