humanmade / hm-redirects

Fast and scalable redirects plugin for WordPress
29 stars 10 forks source link

Support preserving URL Query Parameters #56

Closed roborourke closed 2 years ago

roborourke commented 2 years ago

Uses an option to store query parameters that should be accounted for as redirect targets. These are removed during sanitisation and normalisation and then any unknown query parameters are re-appended after finding a matching redirect rule.

Preserves the ability to add redirects from URLs with query strings. It normalises the query string to sort the keys.

This will really need some migration tool adding before its ready.

Open to thoughts and suggestions for improvements or alternative approaches.

joehoyle commented 2 years ago

I guess the current functionality is only to match against the query params in the URL?

Just a suggestion: could we instead just ignore query strings in the "redirect from" and always forward them? Is anyone using HM Redirects to redirect "http://example.com?foo" specifically?

roborourke commented 2 years ago

I guess the current functionality is only to match against the query params in the URL?

Currently when it hashes the incoming URL that includes query strings, in the database it has a hash of whatever is in the from URL field, which could include a query string or not.

Just a suggestion: could we instead just ignore query strings in the "redirect from" and always forward them? Is anyone using HM Redirects to redirect "http://example.com?foo" specifically?

I can't really say for certain if they do or not, only that it's currently supported. I want to avoid breaking back compat if at all possible.

roborourke commented 2 years ago

Closing in favour of #55, not going to worry about back compat in this instance.