bnomei / kirby3-redirects

Setup HTTP Status Code Redirects from within the Kirby Panel
https://forum.getkirby.com/t/kirby3-redirects-setup-http-status-code-redirects-form-within-the-panel/23581
MIT License
22 stars 2 forks source link
301 302 307 308 header kirby3 kirby3-cms kirby3-plugin performance redirect redirects status-codes

Kirby Redirects

Release Downloads Build Status Coverage Status Maintainability Twitter

Setup performant HTTP Status Code Redirects from within the Kirby Panel.

Kirby Redirects can redirect any request URI to any response URI. It can also handle querystrings and regex.

Similar Plugin

Works well with

Installation

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-redirects instead.

Usage

In the structure field or using the provided site methods add Request-URIs fromuri like

and set Response-URIs touri like

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.

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
only-empty-results false only redirect if the result is empty in the router
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

MIT

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