Skip to content

Correctly implement Redirect feature #8

@8eecf0d2

Description

@8eecf0d2

This is a pretty insane feature considering what it's called, what it's actually capable of, and how it's implemented...

Notice: It's confusing and important to understand if the "redirect rule" in question is a true 3xx style redirect or a more fancy rewrite.

The main features to implement:

  • Traditional Redirect
  • Traditional Rewrite (to filesystem / build.publish)
  • Proxy Rewrite
  • Placeholder / Pattern matching

Redirect Features

Basic Redirects / Rewrites, Http Status Codes

Netlify will return status code 301 for what it calls basic redirects.
Netlify will perform a rewrite if a status code is set and not equal to 301, 302, 303.

  • Support "basic redirect"
  • Support "basic rewrite"

Custom 404

By default Netlify will serve a 404.html file if it's provided and no redirect rules or static files match the path.

  • Support for custom 404.html

Trailing Slashes

I'm not even gonna bother with this yet...

Placeholders

Basically param swapping between from and to - should be easy enough to implement with express and a url pattern library.

from = "/:partA/:partB"
to = "/:partB/:partA"
# "/foo/bar" → "/bar/foo"
  • Support placeholder / pattern replacement

Splats 🤦‍♀️

Similar to placeholders except the * and :splat param are bound.

  • Support special splat placeholder

Query Params

More or less states that query params can be used as placeholders, the syntax is weird but toml is luckily more readable that Netlify's _redirect file formatting.

  • Support query placeholder

Hostnames & Protocols, GeoIP & Language

These feature are getting way beyond my personal use cases - plus I don't see them being entirely useful for local development, it'd be great to support them but I'm not holding my breath.

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions