netlify / ask-netlify

A place to submit questions for Netlify to answer in tutorials, podcasts and blog posts
https://ask.netlify.com
32 stars 8 forks source link

Redirects lookup order (_redirects then netlify.toml) ? #17

Closed talves closed 5 years ago

talves commented 5 years ago

About me

My question in a little more detail

Am I correct to assume the redirects lookup order ( _redirects then netlify.toml)? In my tests this is working just fine but I want to be safe in assuming we can use this in our solutions. This would be great to be able to count on this being a general rule.

Based on the 2 files below in my repo: https://netlify-redirects--shorter.netlify.com/test redirects to https://netlify.com prior to: https://netlify-redirects--shorter.netlify.com/.netlify/functions/redirect/test

_redirects

/google https://google.com 302
/test https://netlify.com 302

netlify.toml

[build]
  command = "npm run build:redirects && npm run build"
  functions = ".netlify/functions/"

[[redirects]]
  from = "/"
  to = "/.netlify/functions/redirect"

[[redirects]]
  from = "/:code"
  to = "/.netlify/functions/redirect/:code"
  status = 200
  force = true

Anything other comments for Netlify

Redirects in Netlify are so powerful and fast and should really be understood by everyone using the ADN 😀

philhawksworth commented 5 years ago

Answered in Ep2 - coming soon: https://ask.netlify.com/episode/02/