kirby3-redirects
kirby3-redirects copied to clipboard
Setup HTTP Status Code Redirects from within the Kirby Panel
Kirby 3 Redirects
Setup performant HTTP Status Code Redirects from within the Kirby Panel.
Kirby 3 Redirects can redirect any request URI to any response URI. It can also handle querystrings and regex.
Similar Plugin
- kirby-retour but it can only handle Kirby Routes. It is the better choice when updating a Kirby 2 project or creating a brand new Kirby 3 project.
Works well with
- CSV Plugin to help you import and export data to the redirects structure.
Commercial Usage
Support open source!
This plugin is free but if you use it in a commercial project please consider to sponsor me or make a donation.
If my work helped you to make some cash it seems fair to me that I might get a little reward as well, right?
Be kind. Share a little. Thanks.
‐ Bruno
| M | O | N | E | Y |
|---|---|---|---|---|
| Github sponsor | Patreon | Buy Me a Coffee | Paypal dontation | Hire me |
Installation
- unzip master.zip as folder
site/plugins/kirby3-redirectsor git submodule add https://github.com/bnomei/kirby3-redirects.git site/plugins/kirby3-redirectsorcomposer require bnomei/kirby3-redirects
Setup
Add the plugin-redirects section to your site.yml and add redirects in the panel.
site.yml
sections:
# ...other sections
redirects:
extends: plugin-redirects3xx
If you need all http codes you can use
extends: plugin-redirectsinstead.
Usage
In the structure field or using the provided site methods add Request-URIs fromuri like
projects/coolprojects?id=123projects/cool.htmlprojects\/.*\.htmlblog\/(?P<year>\d{4})_(?P<slug>.*)\.html
and set Response-URIs touri like
projects/changed-slughttps://exter.nalblog/$year/$slug
as well as a HTTP Status Code code like 301 or 302.
This makes it the ideal choice when porting a non Kirby project.
Site Methods
The site methods appendRedirects and removeRedirects allow you to programmatically change the redirects table (if stored in a Page/Site-Object).
// 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'],
]);
Protecting your Kirby from Bots
This plugin will block various routes of other popular CMS. It is enabled by default and will reduce the load on your website caused by bots looking for vulnerabilities in other CMS.
- Wordpress
- Joomla
- Drupal
- Magento
- Shopify
Settings
| bnomei.redirects. | Default | Description |
|---|---|---|
| code | 301 |
|
| querystring | true |
do keep querystring in request URI. example: https://kirby3-plugins.bnomei.com/projects?id=12 => projects?id=12 |
| map | callback |
A closure to get the structure from content/site.txt. Define you own if you want the section to be in a different blueprint or skip the blueprint and just use code. |
| block.enabled | true |
Block various routes of other popular CMS |
Disclaimer
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.
License
It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.
Credits
This plugins is similar yet way less powerful than K2 version of
- https://github.com/ivinteractive/kirbycms-redirects