Dynamic redirects (Regex/Wildcards)

Taking a look at the new redirect feature in the XDN console it looks like it doesn’t support complex redirects, such as regexes.

We would like to do redirects using wildcards/regexes e.g.
^/connect-with-travel-bloggers/travel-blogger/(.*) => /connect-with-travel-bloggers/$1

What’s the recommended way to achieve something like this?

The XDN console redirects are meant to cover a case where customers have tens of thousands of concrete path redirects rather than complex conditions. For more nuanced cases you should use the XDN router which supports complex path matching as well as matching on HTTP method, headers and cookies.

.get('/connect-with-travel-bloggers/travel-blogger/:path*', ({ redirect }) => {
  redirect('/connect-with-travel-bloggers/:path*')
})

You can see more on the redirect method at https://developer.moovweb.com/docs/api/core/classes/router_responsewriter.responsewriter.html#redirect.

1 Like