Open sutterseba opened 1 week ago
Yeah, I think this shouldn't be super hard to do.
As you noted, there's currently a configuration option to tell if the extra path should be appended when redirecting. This option accepts true
and false
values.
I would probably deprecate this option and replace it with a more flexible one that accepts a set of values that would determine how to match short URLs when an extra path is found:
default
: Any extra path will result in no short URL matched (404). Equivalent of passing false
for current REDIRECT_APPEND_EXTRA_PATH
option.append
: The extra path is appended before redirecting. Equivalent of passing true
for current REDIRECT_APPEND_EXTRA_PATH
option.ignore
: The new behavior requested here.The last two options would be handled in ExtraPathRedirectMiddleware
, ignoring the $extraPath
if the option is configured as ignore
.
Summary
Currently, there is a config option "Append extra path", which will append extra paths in the URI to the destination, e.g. /example/blah will forward to destination.com/blah.
A similar config option that does not append additional paths to the destination and instead ignores them would be great and should be quite simple to implement.
Use case
This would generally allow distinguishing URLs from each other outside the native tracking/tagging solutions. In my case, I have a lot of old URLs with lots of different additional paths (due to how our old URL shortener worked) which would currently all break with Shlink.