hm-redirects icon indicating copy to clipboard operation
hm-redirects copied to clipboard

Always store full URLs for redirects

Open fklein-lu opened this issue 7 years ago • 2 comments

The redirect storage in its current form is not consistent:

  • The From field needs to be a relative URL (path and possibly query arguments). Full URLs will not be matched, as per #16.
  • The To field can be a relative or an absolute URL. Relative URLs will be prefixed with the home_url().

We should switch to the following:

  • Both URLs should be stored as absolute URLs.
  • The UI should indicate the domain of the Form URL, by displaying the home_url() before the text field. If we're on a single si
  • The URL saving function should ensure that only URLs with the home_url() are allowed in the From field.
  • The UI should indicate the domain of the To URL. If there are more domains whitelisted for redirects, a dropdown should be displayed.
  • The URL saving function should ensure that only whitelisted domains are allowed to be saved to the database.

fklein-lu avatar Jun 15 '18 16:06 fklein-lu

Given the redirect matching is done on the path why store the full URL in the "From" field?

Storing the full URL in the "To" field adds a step to migrating a site to a new domain too. Perhaps not an issue if you'd need to do a search-replace anyway but I'm not sure I follow what the benefit is to the proposed data storage solution.

Big +1 for validating using the whitelisted domains.

roborourke avatar Mar 28 '19 16:03 roborourke

Rather against this: Storing the full "To" URL would:

  • Hardcode the domain name thus making local-intended/specific redirects unmovable from one domain to another
  • Loose (or make harder) their distinctive nature. (Not able to add a trailing-slash needed for WP local URLs)

drzraf avatar Jun 19 '23 16:06 drzraf