Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Redirection problem

Started by Muut Archive 10 years ago · 3 replies · 354 views
10 years ago

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?

10 years ago

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)...

10 years ago

@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:

TXT
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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2955 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago