有关Netlify重定向的占位符的问题

时间:2019-05-16 16:30:42

标签: redirect url-rewriting pattern-matching url-redirection netlify

我正在尝试在Netlify中设置一些URL重写。

我想设置重写以重定向

https://example.com/blog/2019/05/15/hello.html

https://example.com/blog/2019/05/hello.html

我阅读了文档-https://www.netlify.com/docs/redirects/#placeholders

  

您可以在原始路径和目标路径中使用占位符:

/news/:year/:month/:date/:slug  /blog/:year/:month/:date/:slug
     

这会将URL /news/2004/02/12/my-story重定向到/blog/2004/02/12/my-story

我有这样的_redirects文件:

# Redirect old permalinks to new format
/blog/:year/:month/:date/:slug.html /blog/:year/:month/:slug.html 301!

重定向确实有用

https://example.com/blog/2019/05/15/hello.html

https://example.com/blog/2019/05/hello.html

但是有一个奇怪的问题,它还会重定向

https://example.com/blog/2019/05/not-a-date/index.html

https://example.com/blog/2019/05/index.html

我的问题是,它能否(如果可以,如何)使:date占位符仅匹配 day not-a-date显然不是日期,:date是否应该仅将0131匹配?

2 个答案:

答案 0 :(得分:0)

据我所知,没有键入占位符(仅允许输入数字)。因此,任何事物都将匹配,并且不可能仅将天定义为匹配模式。

答案 1 :(得分:0)

https://www.healingislands.com/* http://www.힐링아일랜드한의원.com:splat 301!

将{/ *}放在第一个链接的末尾,然后将{:splat 301! }这最后对我有用