Hey, it looks like youre trying to redirect through query parameters. While the query parameters should now be passed through automatically, I think you’d need to specify them. Winging it here but maybe something like this:
[[redirects]]
from = “/”
to = “/booking”
status = 301
query = {url = "bybarner.dk", id = "1184"}
The reason i’ve changed from to “/” is because I think you need this redirect to be applied at that route but only when the specified paramters are applied? If you need it to react to more dynamic url,id values you can use :url :id. (I hope)
[[redirects]]
from = "/"
to = "/"
status = 301
query = {url = "bybarner.dk", id = "1183"}
[[redirects]]
from = "/"
to = "/booking"
status = 301
query = {url = "bybarner.dk", id = "1184"}
[[redirects]]
from = "/"
to = "/behandlinger"
status = 301
query = {url = "bybarner.dk", id = "1185"}
[[redirects]]
from = "/"
to = "/om-os"
status = 301
query = {url = "bybarner.dk", id = "1186"}
Hmm, I’m Sorry for miss informing you! However, I think the query string specification is only to define what parameters to pass through, not the specific slug values.
It seems as though you can only pass on the values. IE:
from = “/”
to = /example/:id
id = :id
@Dennis I’ve tagged Dennis here just for confirmation that this hasn’t changed, as I’ve read a few replies from him on the topic now.
You could probably implement your own formatting to redirect as you need though.
No worries, it was a suggestion which I thought would work as well
Without a doubt I’m a newbie at this, but my issue at hand is that I can’t quite figure out how to handle a fully queried path to a completely different path.
I’ll wait and see what Dennis replies - in the meantime I’ll try doing a _redirect file instead.
Hey, I notice it’s been some time now. Have you managed to find a solution?
I’ll tag another staff member @Scott to see if we can get a more official response.
TLDR pie: Looking to redirect based on query slug values
Recent changes to how query string parameters are handled will mean that the query string parameters are automatically passed through to the new URL. Therefore, your users will actually end up at /booking?url=bybarner.dk&?id=1184. If you don’t want this to happen, you can follow the steps under Query String Parameters in this guide to append a ‘dummy’ parameter. Therefore, your rule would look something like:
Great solution, for my own edification is there a way to do this in a toml file as I tend to find it cleaner. Interesting that there’s a difference in functionality here.
@Scott I tried your approach last night and it works like a charm. force = true was the key to solving my issue. Thank you for your help and your’s as well @AaronP
It does make sense. The prior attempt I had was based on value placeholders instead of static values - that meant I didn’t want to force the redirect since it was only current with a specific set of values.
That being said, it could be nice doing a redirect where the piping of query params could be block completely since /?no-query is a bit hacky