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

Using glob with capture for rewrites #70

Open
laran opened this issue Oct 16, 2018 · 1 comment
Open

Using glob with capture for rewrites #70

laran opened this issue Oct 16, 2018 · 1 comment

Comments

@laran
Copy link

laran commented Oct 16, 2018

Here's the closest example to what I want to do for rewrites that I found:

{
  "rewrites": [
    { "source": "/projects/:id/edit", "destination": "/edit-project-:id.html" },
  ]
}

What I really want to do is have

  • /pages/** all handled by /index.html
  • /tags/** all handled by /index.html

But I don't want to rewrite the url. I just want to have all requests be handled by my react app, the entry point for which is index.html.

What I find now is that if I go directly to a page (let's say /pages/foo), or do a forced refresh of that page, react doesn't load/route properly and returns a 404.

So what rules do I need to have all requests under the specific paths /pages/** and /tags/** all handled by /index.html but without changing the URL?

@warren-bank
Copy link

a few quick thoughts:

  • a redirect would simplify things
  • a rewrite will load the content of your "destination" file at the requested URL
    • which will break relative links..
    • so make sure the "destination" file only uses absolute paths (ie: begin with /)

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