PHPackages                             bnomei/kirby3-redirects - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. bnomei/kirby3-redirects

ActiveKirby-plugin[Security](/categories/security)

bnomei/kirby3-redirects
=======================

Setup performant HTTP Status Code Redirects from within the Kirby Panel

5.1.0(8mo ago)269.1k↓56.7%2[1 PRs](https://github.com/bnomei/kirby3-redirects/pulls)MITPHPPHP &gt;=8.2CI passing

Since Oct 9Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/bnomei/kirby3-redirects)[ Packagist](https://packagist.org/packages/bnomei/kirby3-redirects)[ Docs](https://github.com/bnomei/kirby3-redirects)[ RSS](/packages/bnomei-kirby3-redirects/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (47)Used By (0)

Kirby Redirects
===============

[](#kirby-redirects)

[![Kirby 5](https://camo.githubusercontent.com/b1a1b2ccd58e96259a9722c2489d91f40378c01b6c4c3e9fd27ed1d12c269d7c/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f4b697262792f353f636f6c6f723d454343373438)](https://getkirby.com)[![PHP 8.2](https://camo.githubusercontent.com/fd050028b4459f3f6e4db5703412957375ceb180d27951213d421eb2a23c8c8e/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f5048502f382e323f636f6c6f723d3445354239332669636f6e3d706870266c6162656c)](https://camo.githubusercontent.com/fd050028b4459f3f6e4db5703412957375ceb180d27951213d421eb2a23c8c8e/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f5048502f382e323f636f6c6f723d3445354239332669636f6e3d706870266c6162656c)[![Release](https://camo.githubusercontent.com/7f2fec8a4635a9219fb1bbe29edb02f4af5751683ed1aba88528e7eacf7438b7/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d7265646972656374733f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/7f2fec8a4635a9219fb1bbe29edb02f4af5751683ed1aba88528e7eacf7438b7/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f626e6f6d65692f6b69726279332d7265646972656374733f636f6c6f723d6165383166662669636f6e3d676974687562266c6162656c)[![Downloads](https://camo.githubusercontent.com/f49df4413a7fa698bac5f1d1d372c43bfca7cbd57c657f30e54058a0b83a6d10/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d7265646972656374733f636f6c6f723d3237323832322669636f6e3d676974687562266c6162656c)](https://camo.githubusercontent.com/f49df4413a7fa698bac5f1d1d372c43bfca7cbd57c657f30e54058a0b83a6d10/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f626e6f6d65692f6b69726279332d7265646972656374733f636f6c6f723d3237323832322669636f6e3d676974687562266c6162656c)[![Coverage](https://camo.githubusercontent.com/881627fd4733d407036310f8304b90f79d5889fb7fc203b99ce948e47197c282/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f636f7665726167652f626e6f6d65692f6b69726279332d7265646972656374733f69636f6e3d636f6465636c696d617465266c6162656c)](https://codeclimate.com/github/bnomei/kirby3-redirects)[![Maintainability](https://camo.githubusercontent.com/f9a49183c63db8958c98c56487f561eacabd0f6e8bc857d74b22a9468d3be0c4/68747470733a2f2f666c61742e62616467656e2e6e65742f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f626e6f6d65692f6b69726279332d7265646972656374733f69636f6e3d636f6465636c696d617465266c6162656c)](https://codeclimate.com/github/bnomei/kirby3-redirects/issues)[![Discord](https://camo.githubusercontent.com/36eaef1b06f4996feb7587aa3281dcbd658e57535bc6b5e10110ed108e7a7a03/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f646973636f72642f626e6f6d65693f636f6c6f723d3732383964612669636f6e3d646973636f7264266c6162656c)](https://discordapp.com/users/bnomei)[![Buymecoffee](https://camo.githubusercontent.com/62e55d1129b82bf9c2fd4656451e81ab87a9787e7c9676ca58276532ed9666ee/68747470733a2f2f666c61742e62616467656e2e6e65742f62616467652f69636f6e2f646f6e6174653f69636f6e3d6275796d6561636f6666656526636f6c6f723d464638313346266c6162656c)](https://www.buymeacoffee.com/bnomei)

Features
--------

[](#features)

- ✏️ Define [HTTP Status Code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection) redirects from within the **Kirby Panel**.
- 🔀 Setup redirects from any request URI to any response URI, not just Kirby routes.
- 🕵️ Match on query-strings like `?foo=bar` and forward data with regex `(?P\d{4})`.
- 🛡️ Protects your website from attacks by blocking 50+ routes/patterns of other popular CMS.
- 🪝 With the hooks you can add custom logic like logging 404s.
- 🏎️ Highly performant due to caching on repeated valid requests.

Installation
------------

[](#installation)

- unzip [master.zip](https://github.com/bnomei/kirby3-redirects/archive/master.zip) as folder `site/plugins/kirby3-redirects` or
- `git submodule add https://github.com/bnomei/kirby3-redirects.git site/plugins/kirby3-redirects` or
- `composer require bnomei/kirby3-redirects`

Setup: add Redirects section to Site blueprint
----------------------------------------------

[](#setup-add-redirects-section-to-site-blueprint)

Add the `plugin-redirects` section to your `site.yml`. This will allow you to create redirects in via the Panel or programmatically.

**site/blueprints/site.yml**

```
sections:
    # ...other sections
    redirects:
        extends: plugin-redirects3xx
```

Tip

If you want to able to set all HTTP Status code from within the panel, not just the 3xx range, you can use `extends: plugin-redirects` instead.

Tip

Instead of using the site blueprint you can also use the `redirects` section in any pages blueprint as long as you adjust the `bnomei.redirects.map` option accordingly so the plugin knows where to find the redirects.

Usage
-----

[](#usage)

In the Structure Field within the Panel add a Request-URIs `fromuri`, set a Response-URIs `touri` and a HTTP Status Code `code` like `301` or `302`.

fromuritocode`projects/cool``projects/changed-slug``301``projects/cool.html``projects/changed-slug``301``projects\/.*\.html``projects/changed-slug``301``some/broken-link``https://exter.nal``301``blog\/(?P\d{4})_(?P.*)\.html``blog/$year/$slug``301`Shielding your website from attacks
-----------------------------------

[](#shielding-your-website-from-attacks)

This plugin will **block 50+ routes/patterns** of other popular CMS. It is enabled by default and will reduce the load on your website caused by bots/attackers looking for vulnerabilities found in other CMS.

- Drupal
- Joomla
- Magento
- Shopify
- Wordpress

You can track any redirects, including the blocked requests from the *shield*, using the `redirect:before` and `404:before` hooks.

Hooks
-----

[](#hooks)

This plugin will trigger the following hooks, which you could use to build your own tracking or logging.

- `redirect:before($code, $redirect)`
- `404:before($route, $path, $method)`

**site/config/config.php**

```
