You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Netlify 301重定向失效求助:配置_redirect文件后仍无效果

Troubleshooting Netlify 301 Redirect Not Working

Let’s walk through the most common issues that might be blocking your /blog → /news redirect from working on Netlify:

1. Double-check the filename spelling

Netlify relies on a file named _redirects (note the plural ending: "s")—not _redirect (singular). If you named the file without the final "s", that’s almost certainly the root cause. Verify the exact filename in your repository’s root directory.

2. Validate the redirect rule syntax

Your _redirects file needs to follow Netlify’s strict formatting rules. For a simple permanent 301 redirect, the line should look exactly like this (use two spaces to separate each segment, no tabs):

/blog  /news  301
  • The 301 flag is optional for permanent redirects, but including it makes your intent explicit.
  • If /blog is a directory with subpages (like /blog/post1), use a wildcard rule to catch all paths under it:
    /blog/*  /news/:splat  301
    

3. Confirm the file is in the correct deploy directory

The _redirects file must live in Netlify’s publish directory—this is the folder Netlify actually deploys (e.g., public, dist, or your repo root if you’re deploying static files directly). If it’s tucked away in a subfolder that’s not included in your deploy output, Netlify won’t detect it.

4. Inspect Netlify’s deploy logs

Head to your Netlify site dashboard → Deploys → select the latest deploy → navigate to the "Deploy log" tab. Search for the word "redirects"—you should see a line like Processing redirect rules from _redirects. If this line is missing, Netlify isn’t finding your redirect file at all.

5. Test bypassing browser cache

Sometimes cached responses can make it look like the redirect isn’t working. Test in an incognito window, or use this curl command to check the raw server response:

curl -I https://peaceful-swanson-2960b1.netlify.com/blog

Look for a Location: /news header and a 301 Moved Permanently status code in the output—this confirms the redirect is configured correctly on Netlify’s end.

6. Check for conflicting rules

If you have other redirect rules in _redirects or netlify.toml, ensure none take precedence over your /blog rule. Netlify processes rules top-to-bottom, so place more specific rules above general ones.

If none of these steps resolve the issue, sharing your full GitHub repository link would help dig deeper into your exact setup!

内容的提问来源于stack exchange,提问作者user9748969

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:37:32