Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "redirects" configuration #50

Closed
mbleigh opened this issue Feb 28, 2014 · 9 comments
Closed

Add "redirects" configuration #50

mbleigh opened this issue Feb 28, 2014 · 9 comments
Milestone

Comments

@mbleigh
Copy link
Contributor

mbleigh commented Feb 28, 2014

We need to support redirection via the superstatic JSON config. Like so:

{
  "redirects": {
    "some/path/goes/here":"other/path/here",
    "some/wilcard/:segment/path":"other/wilcard/:segment/path",
  }
}

By default, redirects should use the 301 status. However, the user can specify a custom status like so:

{
  "redirects": {
    "some/path/here": [302, "other/path/here"]
  }
}

T

@mbleigh
Copy link
Contributor Author

mbleigh commented Feb 28, 2014

Note that this requires a new route parsing rule: colon-based segments. We can talk about this more, but basically need to be able to redirect segments dynamically and this is the best way I can think to do it. Open to comment.

@scottcorgan
Copy link
Contributor

What do you mean by "segments"?

@mbleigh
Copy link
Contributor Author

mbleigh commented Feb 28, 2014

URL segments. So :name matches an entire URL segment and can be used in the destination.

e.g. {"/some/:path/here":"/other/:path"} matches /some/thing/here and redirects to /other/thing

@scottcorgan
Copy link
Contributor

That makes sense. I already have a module that will make those segments very easy.

Recommendations:

  1. I recommend we use the "routes" object for redirects. It already handles redirects and it's one less config object in the json file.
  2. I recommend we configure status codes like this:
{
  "routes": {
    "/some/path": {
      "status": "302",
      "path": "/some/other/path/redirectied"
    }
  }
}

This makes less confusion as to where the status and the path go in the array for the user.

@mbleigh
Copy link
Contributor Author

mbleigh commented Feb 28, 2014

We already handle redirects in the routing? I thought it was only rewrites. How do redirects currently work in routes?

@scottcorgan
Copy link
Contributor

I lied. The only redirects that happen are for clean urls and directory indexes. We should add a redirects object.

@mbleigh
Copy link
Contributor Author

mbleigh commented Feb 28, 2014

Yeah, and you're right it should be plural since routes is plural.

@scottcorgan
Copy link
Contributor

NOTE: providing a url redirects to that url. Providing a path, redirects only to that path

@mbleigh mbleigh changed the title Add "redirect" configuration Add "redirects" configuration Apr 4, 2014
scottcorgan pushed a commit that referenced this issue Apr 29, 2014
Some support for redirects. Ref #50
@mbleigh
Copy link
Contributor Author

mbleigh commented May 6, 2014

Let's do status, not statusCode. For one thing, we have generally used an underscore convention for Superstatic config, for another it's more succinct and I like it better.

@scottcorgan scottcorgan added this to the 0.10.0 milestone May 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants