用Netlify重写 [英] Rewrites with Netlify
问题描述
我正在尝试在Netlify中设置一些重写.这是我的_redirects
文件中的内容:
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
第一行按预期工作,第二行不工作.但是,如果我将第二行的HTTP状态代码更改为301,则可以正常工作.为什么?我真的需要像第二行中的规则一样进行重写.我还可以做其他修改以使其起作用吗?
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?
推荐答案
我收到了Netlify电子邮件支持的回复.
I got a response from Netlify email support.
将路径传递给重定向作为查询参数并不意味着可以正常工作, 尤其是200级状态.
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
这篇关于用Netlify重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!