Redirection problem

Hi, I’ve got a problem with redirection. I want to redirect a page /doc/admin to /doc/v2/admin, that works fine. But now I want to call /doc/admin/domain-join but get redirect to /doc/v2/admin.

Is the redirection page specific? Can someone help me?

You need to set the redirect using regular expression, see the explanation

I’ve already tried that.

Here some more details
I need:
/doc/admin -> /doc/v2/admin
/doc/admin/domain-join (no redirect)

I have:
/doc/admin -> /doc/v2/admin
/doc/admin/domain-join -> /doc/v2/admin

As redirect rules I tried:
/doc/admin: /doc/v2/admin
/doc/admin$: /doc/v2/admin
/doc/(admin|user)$: /doc/v2/$1

Thanks for any help you can give is really appreciated. I don’t know where the bug is (probably in my thinking)…

@dfuhrmann The regular expression used for custom routes and redirects are not anchored (see i.e. https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Page/Pages.php#L332 ). It means that your first route matches although the match is only a subset of your real path (here: “/doc/admin/domain-join”). If you feel that’s a bug, please report it at the Grav issue tracker https://github.com/getgrav/grav/issues .

I think what you want is this:

redirects:
  "^/doc/(admin|user)/?$": "/doc/v2/$1"

This will redirect /doc/admin -> /doc/v2/admin and /doc/user -> /doc/v2/user, but ignore routes like /doc/admin/domain-join etc.

Sommerregen