bnomei / kirby3-redirects
从 Kirby 控板内设置高性能 HTTP 状态码重定向
4.2.1
2024-09-17 15:55 UTC
Requires
- php: >=8.1
- getkirby/composer-installer: ^1.2
Requires (Dev)
- getkirby/cms: ^4.1.0
- php-coveralls/php-coveralls: ^2.4
- phpunit/phpunit: ^9.5
- spatie/ray: ^1.41
Suggests
- bnomei/kirby3-csv: Adds functions to import and export data from structures (like the redirect table)
- bnomei/kirby3-feed: Add xml-rss and/or json feed
- bnomei/kirby3-robots-txt: Automatic robots.txt. Detects xmlsitemap.
- bnomei/kirby3-security-headers: CPS headers to make the the web a saver place. Sensible defaults with zero configuration.
- dev-master
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.0
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.3
- 1.2.1
- 1.2.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- dev-dependabot/composer/guzzlehttp/psr7-2.5.0
This package is auto-updated.
Last update: 2024-09-17 15:55:30 UTC
README
从 Kirby 控板内设置高性能 HTTP 状态码 重定向。
Kirby 3 重定向可以将任何请求 URI 重定向到任何响应 URI。它还可以处理查询字符串和正则表达式。
类似插件
- kirby-retour 但它只能处理 Kirby 路由。当更新 Kirby 2 项目或创建全新的 Kirby 3 项目时,它是更好的选择。
兼容性
- CSV 插件 帮助您将数据导入和导出到重定向结构中。
商业用途
支持开源!
此插件是免费的,但如果您将其用于商业项目,请考虑赞助我或进行捐赠。
如果我的工作帮助您赚了钱,我认为我可能也应该得到一点回报,对吧?
善良一点。分享一点。谢谢。
—— Bruno
安装
- 解压 master.zip 为文件夹
site/plugins/kirby3-redirects
或 git submodule add https://github.com/bnomei/kirby3-redirects.git site/plugins/kirby3-redirects
或composer require bnomei/kirby3-redirects
设置
将 plugin-redirects
部分添加到您的 site.yml
,并在面板中添加重定向。
site.yml
sections: # ...other sections redirects: extends: plugin-redirects3xx
如果您需要所有 HTTP 状态码,可以使用
extends: plugin-redirects
。
用法
在结构字段或使用提供的站点方法中,添加请求 URI fromuri
,例如
projects/cool
projects?id=123
projects/cool.html
projects\/.*\.html
blog\/(?P<year>\d{4})_(?P<slug>.*)\.html
并设置响应 URI touri
,例如
projects/changed-slug
https://exter.nal
blog/$year/$slug
以及 HTTP 状态码 code
,例如 301
或 302
。
这使得它成为迁移非 Kirby 项目的理想选择。
站点方法
站点方法 appendRedirects
和 removeRedirects
允许您以编程方式更改重定向表(如果存储在页面/站点对象中)。
// add single item $success = site()->appendRedirects( ['fromuri'=>'/posts?id=1', 'touri'=>'/blog/1', 'code'=>301] ); // add multiple items with nested array $success = site()->appendRedirects([ ['fromuri'=>'/posts?id=2', 'touri'=>'/blog/2', 'code'=>301], // ... ['fromuri'=>'/posts?id=999', 'touri'=>'/blog/999', 'code'=>301], ]); // remove single item $success = site()->removeRedirects( ['fromuri'=>'/posts?id=1', 'touri'=>'/blog/1'] ); // remove multiple items with nested array $success = site()->removeRedirects([ ['fromuri'=>'/posts?id=3', 'touri'=>'/blog/3'], ['fromuri'=>'/posts?id=5', 'touri'=>'/blog/5'], ['fromuri'=>'/posts?id=7', 'touri'=>'/blog/7'], ]);
保护您的 Kirby 免受机器人侵害
此插件将阻止其他流行 CMS 的各种路由。默认情况下启用,并将减少机器人查找其他 CMS 漏洞造成的网站负载。
- Wordpress
- Joomla
- Drupal
- Magento
- Shopify
设置
免责声明
本插件提供“原样”且无任何保证。请自行承担风险使用,并在生产环境中使用前自行测试。如果您发现任何问题,请 创建新问题。
许可协议
不建议在任何推广种族主义、性别歧视、同性恋恐惧症、动物虐待、暴力或其他任何形式仇恨言论的项目中使用此插件。
鸣谢
此插件与K2版本的插件相似,但功能要弱得多。