Rewrites with Netlify

2019-08-15 03:17发布

问题:

I am trying to set up some rewrites in Netlify. Here's what I have in my _redirects file:

/search xyz=:abc    https://example.com/search?xyz=:abc    200
/:abc               https://example.com/search?xyz=:abc    200

The first line works as expected, the second line is not working. However, if I change HTTP status code for the second line to 301, it works. Why is that so? I really need to rewrite like the rule in second line. Is there any other modification I can do to make it work?

回答1:

I got a response from Netlify email support.

Passing a path to a redirect as a query param is not meant to work, especially as a 200 status.

So I made some minor changes to my server and this alternative redirect rule works fine:

/:abc    https://example.com/search/:abc    200