mrssoft/yii2-url-redirect
Composer 安装命令:
composer require mrssoft/yii2-url-redirect
包简介
Extension for redirection from old url to new one
关键字:
README 文档
README
Extension for redirection from old url to new one.
Configure
Add to config:
'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 ] ], ... ]
Add the table to the database:
CREATE TABLE `redirect` ( `old_url` VARCHAR(255) NOT NULL, `new_url` VARCHAR(255) NOT NULL, `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`old_url`) ) ENGINE=InnoDB
Usage
Add a link to the redirect database:
Yii::$app->redirect->add('/old/url/', '/new/url');
Clear old links:
Yii::$app->redirect->clear('-3 month');
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-14