Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic redirects based on query parameters #1902

Closed
matthiasharrer opened this issue Nov 2, 2023 · 2 comments · Fixed by #2024
Closed

Dynamic redirects based on query parameters #1902

matthiasharrer opened this issue Nov 2, 2023 · 2 comments · Fixed by #2024
Labels
Milestone

Comments

@matthiasharrer
Copy link

matthiasharrer commented Nov 2, 2023

Summary

This feature request originated from the discussion over here: #1901

My main objective is to preconfigure urls that have additional information encoded in them, but ignore that information and use a common long url. Later I might want to start using this information to direct to different long urls. For more details please see the described use case and the linked discussion.

Implementation suggestions that came to my mind:

  • Add additional information as query parameters
    • Disable query parameter forwarding
    • Allow matching query parameters in short urls
      • For example https://short.example.com/abcd?variant=a can be forwarded to a different long url than https://short.example.com/abcd?variant=b
  • Add additional information in the path
    • Url could be https://short.example.com/abcd/a
    • Quite similar to the Extra path forwarding feature we could match on https://short.example.com/abcd and instead of forwarding it just ignore the remaining path
    • This might not be as flexible as the query params because when adding multiple "parameters" to the path we could only match the first without the seconds but not the second without the first. It would make it easier to decide which short url to use if multiple match (because that case is already supported with path forwarding)
    • As an alternative short urls could be defined regexes which would be super flexible but also pose the risk of using evil regexes

I am looking forward to see if anyone else would like to see a similar feature.

Use case

I am using urls to my shlink instance on embedded devices.
For example the url might point to a video explaining how to use that device.
Using shlink allows me to change the actual target the url is pointing to without updating the device itself.

I now currently have the use case, that I want to point to different (long) urls based on some configuration of the device.
This configuration could include:

  • Different branding of the devices
  • Different configured language
  • ...

The key point is that I would like to provide this context from the device (in the "short" url) but still be able to start out with a single long url for all devices (e.g. start with an english video and over time add other languages without having to edit the short url in the device)

@acelaya
Copy link
Member

acelaya commented Nov 5, 2023

Take a look at this RFC. I think it would cover this use case (in fact I wrote it with this use case in mind, among others).

@acelaya acelaya changed the title Match on parts of the url / encode additional non-matched information for later use Dynamic redirects based on query parameters Nov 8, 2023
@acelaya acelaya added this to the 4.1.0 milestone Nov 8, 2023
@acelaya acelaya modified the milestones: 4.1.0, 4.0.0 Feb 24, 2024
@acelaya acelaya moved this to In Progress in Shlink Feb 24, 2024
@acelaya acelaya moved this from In Progress to In review in Shlink Feb 26, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Shlink Feb 26, 2024
@acelaya
Copy link
Member

acelaya commented Feb 26, 2024

This is now implemented. Shlink 4.0.0 will support defining dynamic redirects based on any combination of query parameters provided with the short URL.

This is implemented on top of the in-progress logic for dynamic rule-based redirects described in this RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants