When and why to use redirects?

There are different scenarios why you would want to redirect site visitors to another web page:

  • You moved a web page to a new URL. For instance because you wanted to give an existing page a more descriptive URL (for example /redirect-users-to-another-page/ instead of /article-12/). Or maybe you migrated your previous site to the Lean Web Kit and changed all the URLs, like /articles/:article-name/ to simply /:article-name/.
  • You removed a web page and don’t want to serve your visitors something more meaningful and useful than a generic “Page not found”. For example a livestream has ended and you want to redirect users to the edited videos page. So you want to redirect /event-x-livestream/ to /event-x-videos/.
  • You want short memorable URLs so people can remember and type them easily. And you want to reuse that URL for different occasions. For instance /join/ may redirect to /join-masterclass-y/ now, but in the future redirect to /join-event-z/.

As a live example /demo/permanent-redirect/ redirects back to this page.

Configuring redirects

You can add new redirects via CMS > Redirects > ⊕:

Each redirect expects a:

  • From - containing the original URL or URL pattern you want to redirect users away from.
  • To - containing the new URL or URL pattern you want to redirect users to.
  • HTTP Status Code - telling the browser how to interpret the redirect. Your options are:
    • 301 (default) - Permanent redirect. The user is redirected to the To URL. This redirect will never change, so browser can remember it.
    • 302 - Temporary redirect. The user is redirected to the To URL. This redirect may change, so ask server again next time.
    • 200 - Status OK. The page behind the To URL is served under the From URL.
    • 404 - Custom Page not found. The page behind the To URL is served under the FromURL. This page should contain a custom “not found” page.

Behind the scenes, Netlify redirects are used to redirect users. For advanced URL patterns see the Netlify docs on placeholders, splats and query parameters.