Skip to content

Add splat and placeholder support to _redirects

Nathan Friend requested to merge nfriend-add-splat-redirects into master

What does this MR do?

Adds support for Netlify-style splats (*) and :placeholders in _redirects.

This can be used to route all matches to a single, static path:

/foo/* /bar 200

or to a dynamic path using the placeholders:

/foo/*                 /bar/:splat                     200
/foo/:year/:month/:day /bar/blog/:year-:month-day.html 200

Why?

There are a lot of use cases for this feature, but the killer feature for this is to support single page applications (SPAs) that expect the main index.html page to be served for all requests. (See #23 (closed))

This can be accomplished with a configuration like this:

/* / 200

Documentation

This new functionality will be documented in gitlab!59803 (merged)

TODO

Related to #500 (closed)

/_redirects sample with new validations

Screen_Shot_2021-05-03_at_4.18.07_pm

Edited by Nathan Friend

Merge request reports