How to add redirections for all children paths excluding parent path

i’m trying to add redirections for all paths except parent path, i tried the below redirect rules in _redirects file but it doesn’t work.

/media-center/* 301 (works but it overwrites “parent don’t redirect” rules so parent is also redirecting)
/media-center/experts/* /index.html 200! (doesn’t work - redirects to subdomain)
/media-center/index.html /index.html 200! (doesn’t work - redirects to subdomain)

expected results:
All /media-center/* pages should redirect to subdomain
Path with /media-center/experts/* should not redirect
Parent path of /media-center/* i’e (/media-center/index.html) should not redirect

Not sure how “force” flag will work when there is 2 different redirect behavior for parent and children path.

hi there, before we dig in, did you see this brand new guide on debugging redirects?

I strongly suggest you give it a thorough read through and see if this fixes your problem:

if not, please post again, and we’ll try and troubleshoot.

1 Like

@shameer-rahman Are you aware of the Rule processing order?

@SamO i have gone through that documentation previously, it is indeed helpful, but nothing is mentioned about the type of answer i’m looking for.

i have a simple requirement, i’m using gatsbyjs framework, where the pages are generated dynamically, i just want to achieve the following, please let me know if it’s possible using netlify redirects.

  1. redirect all pages using path /media-center/* (works fine)
  2. DO Not redirect the main page (direct parent page i’e /media-center/index.html).

i tried the below redirect rules but the parent rule (i’e rule #1) is not working! rule #2 works fine.

  1. /media-center/index.html /index.html 200!
  2. /media-center/* 301!

@nathanmartin even i tried changing the above rules order it doesn’t work

This should be:

/media-center/ /media-center/index.html 200!