Ghost: Update query params forwarding behavior for redirects.json file

Created on 12 Jul 2019  路  10Comments  路  Source: TryGhost/Ghost

For custom redirects, Ghost currently overwrites query params in to url as they are in from. This means if to url has any query params, they will get overridden to be empty instead if from url has no query params. This is leading to unexpected behavior, specially in cases where to url has explicit query params. Suggested update to behavior -

  1. Merge from and to query params, with from overwriting to
  2. Add option to not include any params from from

This covers _most_ scenarios in which query params override can be used.

bug help wanted routing server / core

Most helpful comment

  • query params in the "from" field should be matched to the "from url"
  • query params in the "to" field should always be kept (ie, take precedence over incoming query params)
  • all other query params are passed through

All 10 comments

  • query params in the "from" field should be matched to the "from url"
  • query params in the "to" field should always be kept (ie, take precedence over incoming query params)
  • all other query params are passed through

This issue also applies to a redirect like this:

[{
"from": "^/media/(.*)$",
"to": "https://storage.googleapis.com/files.domain.com/media/$1",
"permanent": true
}]

In this case the URL works, but not for the $1 part, which is what I would expect and also our docs are describing.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Is there any workaround for this?

Hey @Louvki o/

No workaround that I'm aware of I'm afraid!

We'd welcome a PR if you find the time :ghost:

@Louvki 馃憢, if you create a topic on our forum I might be able to help you with a workaround https://forum.ghost.org

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Hello, @stale. I'm working on this.

Todo

  • [x] to take precedence. URL query params pass through => #12333.
  • [ ] Allow matching query params in the from field.
  • [ ] Add option to ignore URL query params.
Was this page helpful?
0 / 5 - 0 ratings