How to redirect only a specific page with Routes?

I have never worked with Routes, so I still lack the understanding of how it works.
I took the script from the guide and it works as expected.

However, I would like to narrow down the function further.

Instead of using
http://yourdomain.com/blog/my-awesome-article
I can call the page via
http://yourdomain.com/my-awesome-article
to reach the page.

The principle works with ALL pages in the blog. However, I only want to redirect ONE page from the blog via the route: the one titled “action”. All other pages can contain “blog” in the URL.

At which point - and how - do I need to adjust the script?

Hello,

just check the pages Url in a if-statement.

Then don’t use the anyplaceholder, but just the pattern

'blog/action'

for the redirect. No need for an if statement

And the first route can then be limited to action instead of (:any)

Unfortunately, I could only now deal with the issue again but I found the appropriate solution.
It’s about a promotion that is advertised with a short URL and then leads to the landing page:

www.domain.com/aktion
www.domain.com/de/blog/aktion

/site/config/config.php

'routes' => [
[
'pattern' => 'action'
'action' => function () {
go('en/blog/action');
}
]
],

Is there an elegant way to manage such redirects in the panel so that the client doesn’t call me every time I run a promotion?

:clap: I think this plug-in will be the perfect solution:

:question: Surely this can be used to set up redirects when the site switches from WordPress to Kirby?

Ok, this is the exact opposite of what you described in your first post, but glad you solved it.

Yes. Although, it might be better to handle redirects that are not dynamic from your server configuration.