pendalf89/yii2-redirect
最新稳定版本:1.0.3
Composer 安装命令:
composer require pendalf89/yii2-redirect
包简介
Component for convenient URL redirects in Yii2.
关键字:
README 文档
README
Component for convenient URL redirects in Yii2.
Features
- All redirects are stored in the DB
- Fast speed
- Easy installation and usage
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require pendalf89/yii2-redirect
or add
"pendalf89/yii2-redirect": "^1.0.0"
to the require section of your composer.json file.
Create table in your database (MySQL, Postgres etc.)
CREATE TABLE `redirect` ( `source` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `target` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`source`) USING BTREE, KEY `created_at` (`created_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
Configuration:
'on beforeRequest' => function() { Yii::$app->redirect->run(); }, 'components' => [ 'redirect' => 'pendalf89\redirect\Redirect', ],
Installation done.
Usage
Just add your urls to DB:
Yii::$app->redirect->add('https://example.com/from/', 'https://example.com/to/');
After that the redirects will work.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-28