301 Redirect: Many to One Using Wildcards

I need to redirect variants of a url to a single common url using 301 redirects.

Using a wildcard, is it possible to do something to the effect of this:

/info/opt-out-(.*) —> /info/out-out-confirmed
Note: the above does not work

I would like to avoid creating a new 301s (or duplicate /opt-out-confirmed pages!) for every offer that requires a marketing opt out.

/info/opt-out-special-offer-1 —> /info/opt-out-confirmed
/info/opt-out-special-offer-2 —> /info/opt-out-confirmed
/info/opt-out-special-offer-3 —> /info/opt-out-confirmed
...

It’s easy to see how cumbersome managing multiple single-use-case 301s or pages could become.

Use Case:

To workaround the way our CRM handles clicks and tagging, I need to use a dummy url in our marketing messages, like /info/opt-out-special-offer-1.

To do so, I add a 301 redirect in Webflow to redirect /info/opt-out-special-offer-1 —> /info/opt-out-confirmed.

Back in the CRM I create a rule for the dummy url that adds the appropriate tags (e.g. [Pref] Opt Out Special Offer 1 etc). Lastly, I add the rule to the link in the marketing message as a Link Trigger.


Read-Only: LINK

Hey @Zephyr,

I have not tested this personally, but it seems when we use wildcards, we need to escape certain characters in the old path with % as mentioned here.

Can you try escaping the hyphen in your old path and then test out the wildcard redirect pattern that you mentioned above?

1 Like

/info/opt%-out%-(.*) —> /info/opt-out-confirmed = Too many redirects

However:

/prefs/opt%-out%-(.*) —> /info/opt-out-confirmed = redirects brilliantly!

The keys are to use a completely bogus url while escaping the hyphens as @AJ_Dev recommended.

In this case, I do not have a /prefs/ folder in my project and I used the above pattern to properly escape and substitute. Now:

/prefs/opt-out-any-thing-I-want will redirect to the generic /info/opt-out-confirmed page. Only one 301 rule in WF for as many opt out links as we’ll ever need to create in our CRM. Awesome!

Thanks for the recommendation!

1 Like