Netlify重定向不起作用 [英] Netlify Redirect not working

查看:67
本文介绍了Netlify重定向不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以昨天我遇到了一个问题,因为我无法实现301重定向到托管在GitHub页面上的页面.

so yesterday I was having a problem because I wasn't able to implement a 301 redirect to my page hosted on the GitHub pages.

今天我发现Netlify应该能够执行301重定向.但是,有些事情不起作用,文档说我需要在_redirect文件中添加重定向,但没有任何效果.有什么想法我做错了吗?

Today I found Netlify which should be able to do 301 redirects. However something is not working, the docs say I need to add the redirect in a _redirect file, but nothings working. Any ideas what I am doing wrong?

这是测试"页面: https://peaceful-swanson-2960b1.netlify.com/

(当您单击博客时,它应该重定向到新闻)

(It should redirect to news when you click on blog)

这是GitHub Repo:

Here is the GitHub Repo:

https://github.com/vnllab/testy

推荐答案

两件事:

  • 您提到了 _redirect 文件.它应该是 _redirects .

我在重定向时遇到了问题.我花了一段时间才弄清楚,如果我先把一个包罗万象的规则放在首位,其他规则将永远无法实现(至少我认为这是正在发生的事情,我的另一条规则被忽略了……).

I had an issue with a redirect. It took me a while to figure out that if I put a catch-all rule first, the other rules would never be reached (well at least that's what I think was happening, my other rule was ignored...).

此:

/* /index.html 200
http://mysite.netlify.com/* https://mysite.netlify.com/:splat 301!

不起作用,但这:

http://mysite.netlify.com/* https://mysite.netlify.com/:splat 301!
/* /index.html 200

工作正常...

这篇关于Netlify重定向不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆