Why is a redirect not working

I’ve added the following redirect to netlify.toml:

[[redirects]]
  from = "/blog/2023/06/16/fragments-of-capital-fx"
  to = "/posts/2023/06/16/fragments-of-capital-fx"
  status = 301
  force = false

And I have deployed the new files, no errors in deployment, but visiting the old url still returns a 404:

but the new url works:

Why doesn’t the old url get redirected?

@mjgs Is the netlify.toml in the correct location?

Check the Deploy summary in your Deploy log, it should indicate if the redirect was detected.

@nathanmartin Thanks for the reply. I think the netlify.toml is in the right place, I actually list the contents of the site directory in a Github Action step right before running netlify-cli deploy:

Site dir:
total 4.1M
drwxr-xr-x 23 runner docker 4.0K Jun 14 04:38 .
drwxr-xr-x  4 runner docker 4.0K Jun 14 04:37 ..
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:37 .well-known
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 about
drwxr-xr-x  8 runner docker 4.0K Jun 14 04:37 archives
drwxr-xr-x 17 runner docker 4.0K Jun 14 04:36 blog
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 contacts
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 donate
drwxr-xr-x 11 runner docker 4.0K Jun 14 04:37 feeds
-rw-r--r--  1 runner docker 1.8K Jun 14 04:36 feeds.opml
-rw-r--r--  1 runner docker 3.8K Jun 14 04:36 index.html
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 job-interview-policy
drwxr-xr-x 17 runner docker 4.0K Jun 14 04:37 links
-rw-r--r--  1 runner docker 1.7M Jun 14 04:37 listofurls.txt
-rw-r--r--  1 runner docker 6.7K Jun 14 04:37 netlify.toml
drwxr-xr-x  8 runner docker 4.0K Jun 14 04:37 newsletter
drwxr-xr-x  5 runner docker 4.0K Jun 14 04:37 notes
-rw-r--r--  1 runner docker  93K Jun 14 04:38 package-lock.json
drwxr-xr-x  4 runner docker 4.0K Jun 14 04:37 podcast
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 portfolio
drwxr-xr-x 11 runner docker 4.0K Jun 14 04:37 posts
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 pricing
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 recommendations
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 resources
-rw-r--r--  1 runner docker   57 Jun 14 04:37 robots.txt
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 services
-rw-r--r--  1 runner docker 2.2M Jun 14 04:37 sitemap.xml
drwxr-xr-x  2 runner docker 4.0K Jun 14 04:36 sponsorships
drwxr-xr-x  6 runner docker 4.0K Jun 14 04:36 static
drwxr-xr-x  7 runner docker 4.0K Jun 14 04:37 tags

So it’s definitely there.

However the deploy summary page on the netlify.com website has the following messages:

* No redirect rules processed

This deploy did not include any redirect rules.

and

* No header rules processed

This deploy did not include any header rules

So looks like for some reason nothing in netlify.toml is being picked up.

@mjgs I’m not well versed in the CLI so cannot provide instructions specific to that.

When linked to a repository you put the netlify.toml in your Base directory (the root of the repository by default), and not in the Publish directory (the files that are deployed).

If those are the files that you’re deploying, and you’re only trying to do a redirect, you could just switch to using the _redirects format instead.

Make a file called _redirects with

/blog/2023/06/16/fragments-of-capital-fx   /posts/2023/06/16/fragments-of-capital-fx   301

@nathanmartin Thanks for your help so far. I’m reading through docs now to figure out where | need to put the netlify.toml when using netlify-cli to deploy. There isn’t a special flag for it, so the only other place is to stick it in the top level of the files that get published. I might try the _redirects format you mentioned, but I would prefer to have everything in one file, so would be good to hear from somebody at Netlify as to whether netlify.toml works with netlify-cli deployments.

I just found this issue on the netlify-cli: “netlify deploy --dir” is not uploading netlify.toml. Seems relevant.

Folks in the thread were downgrading to version 17.2, and the issue was recently closed as stale. According to my deploy logs current version of netlify-cli:

Version
  @netlify/build 33.4.3

So does that mean netlify-cli has not been uploading netlify.toml for like 2 years?

Well I tried moving the config to seperate _headers and _redirects files:

Site dir:
total 4.1M
drwxr-xr-x 23 runner docker 4.0K Jun 14 08:31 .
drwxr-xr-x  4 runner docker 4.0K Jun 14 08:31 ..
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:31 .well-known
-rw-r--r--  1 runner docker 2.0K Jun 14 08:31 _headers
-rw-r--r--  1 runner docker 4.7K Jun 14 08:31 _redirects
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 about
drwxr-xr-x  8 runner docker 4.0K Jun 14 08:31 archives
drwxr-xr-x 17 runner docker 4.0K Jun 14 08:30 blog
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 contacts
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 donate
drwxr-xr-x 11 runner docker 4.0K Jun 14 08:31 feeds
-rw-r--r--  1 runner docker 1.8K Jun 14 08:30 feeds.opml
-rw-r--r--  1 runner docker 3.8K Jun 14 08:30 index.html
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 job-interview-policy
drwxr-xr-x 17 runner docker 4.0K Jun 14 08:31 links
-rw-r--r--  1 runner docker 1.7M Jun 14 08:31 listofurls.txt
-rw-r--r--  1 runner docker   82 Jun 14 08:31 netlify.toml
drwxr-xr-x  8 runner docker 4.0K Jun 14 08:31 newsletter
drwxr-xr-x  5 runner docker 4.0K Jun 14 08:31 notes
-rw-r--r--  1 runner docker  93K Jun 14 08:31 package-lock.json
drwxr-xr-x  4 runner docker 4.0K Jun 14 08:31 podcast
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 portfolio
drwxr-xr-x 11 runner docker 4.0K Jun 14 08:31 posts
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 pricing
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 recommendations
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 resources
-rw-r--r--  1 runner docker   57 Jun 14 08:31 robots.txt
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 services
-rw-r--r--  1 runner docker 2.2M Jun 14 08:31 sitemap.xml
drwxr-xr-x  2 runner docker 4.0K Jun 14 08:30 sponsorships
drwxr-xr-x  6 runner docker 4.0K Jun 14 08:30 static
drwxr-xr-x  7 runner docker 4.0K Jun 14 08:31 tags

But still the deploy summary says no rules processed.

What else might work?

Just noticed that the format in the _redirects and _headers file is different. Going to try to update them…

Right, updating the formats worked.

The formats are:

And actually they are much more compact formats than netlify.toml.

Thanks for the help.