humanmade / hm-redirects

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

trailing-slash for local URL #74

Closed drzraf closed 6 months ago

drzraf commented 1 year ago

WP common configuration adds a trailing-slash to URL. trailingslashit is in charge for this.

When redirecting to a local URL, omitting the trailing-slash incur another redirect for the purpose of adding the slash. The current code always drop that slash implying two redirections.

svandragt commented 7 months ago

Thanks for your contribution @drzraf it's really appreciated, I just came across a similar issue. The problem is that redirections to other sites that have the same behaviour will still result in a redirection to a trailing slash URL. So just making the exception for local URLs doesn't solve the problem.

The root cause is that the trailing slash is stripped from all TO urls (in sanitise_and_normalise_url()). We're looking at fixing it there.

Sorry for the delay.

roborourke commented 6 months ago

I think the behaviour was perhaps written with external URLs in mind, but it should probably accept what was specifically entered by the user. I think the PR looks good, will do a full review now.