0

I have a _redirects file in my netlify directory structure

 /
 - site
 -- _redirects

_redirects

https://example.netlify.com/  https://www.example.com/:splat 301!
https://www.example.com/post/196 https://www.example.com/comic/post-name

Problem:

The first redirection occurs successfully, but the 2nd one returns:

Page Not found

I have followed the documentation in https://www.netlify.com/docs/redirects/ but cannot find a cause of this issue.

I note 2 potential causes mentioned in the documentation:

You can also add redirect rules to your netlify.toml file.

^^ I have not tried this, but since it reads "also" I assume using _redirects file should be sufficient.

For Jekyll, this requires adding an include parameter to config.yml.)

^^ I am not using Jekyll as far as I know, but my project does contain a config.yml file.

Wronski
  • 1,506
  • 3
  • 18
  • 37

2 Answers2

0

You will not be able to chain redirects on Netlify from what the docs read.

The redirect engine processes the first matching rule it finds, so more specific rules should be listed before more general ones

https://example.netlify.com/post/196 https://www.example.com/comic/post-name
/post/196 /comic/post-name
https://example.netlify.com/*  https://www.example.com/:splat 301!

You can try without the first line above to see if https://example.netlify.com/post/196 redirects to https://www.example.com//comic/post-name. If it does not redirect, then there is no chaining in Netlify redirects.

talves
  • 13,993
  • 5
  • 40
  • 63
  • I tried switching those urls around as per your example. Unfortunately, the result remains the same. > Page Not found – Wronski Oct 23 '18 at 11:14
  • I would make sure you have a `/comic/post-name/index.html` page in your build. – talves Oct 23 '18 at 15:24
  • I am not sure what was required for this page, so did not set it up. Regardless, I found a solution (detailed below). Thank you for your help. – Wronski Oct 25 '18 at 07:49
0

Solved by adding:

[[redirects]]
from = "https://www.example.me/post/196"
to = "https://www.example.me/comic/post-name"
status = 200

to netlify.toml

source of solution: https://www.netlify.com/docs/redirects/

Wronski
  • 1,506
  • 3
  • 18
  • 37