Exclude a route when using wildcard *

I have the following rule inside my TOML file:

from = “/*”
to = “/index.html”
status = 200

However, I’d like to exclude a specific route from being redirected:

When this storybook route is being matched, I want Netlify to serve the build/storybook/index.html file, and not the main SPA (build/index.html) file.

How can this be achieved?

Does this help?

I have tried doing the following and it still redirects me to the SPA when visiting the /storybook route:

  from = "/storybook"
  to = "/storybook/index.html"
  force = true

# The following redirect is intended for use with most SPAs that handle routing internally.
  from = "/*"
  to = "/index.html"
  status = 200

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.

I went through this article and everything seems to be configured correctly.
I even see 2 redirect rules processed in the deploy summary.
However, I still don’t get the behaviour I expect.

If I access the file directly (https://www.mysite.netlify.app/storybook/index.html) I immidiately get the correct file, but trying to enter through the redirect (https://www.mysite.netlify.app/storybook) gets me to my SPA instead.

Any idea why?

interesting - could you post your redirects file please?

Of course.

Another thing that is happening to me right now, is that the Service Worker fails to register, since it’s request is being fullfilled by the index.html file and therefore I get the following error:

Failed to register a ServiceWorker for scope (‘https://flyingnotes.netlify.app/’) with script (‘Flying Notes’): The script has an unsupported MIME type (‘text/html’).

I’m sure this has worked before, I suspect that the fact that I added the storybook redirect made this happen (I also made a drastic change to the SW a few minutes ago, so I may have broken it in the process and it has nothing to do with Netlify’s redirect).

Hi, @theninthsky. The redirect is working when you assess the Netlify site (under flyingnotes.netlify.app).

If you access the site using a custom domain, it isn’t connected to Netlify - not directly anyway. If you navigate to this page you will see there is no custom domain defined here:


We cannot troubleshoot the redirect for the custom domain because the custom domain isn’t connected to Netlify. The custom domain must be pointing to some other service and you will need to contact that service to troubleshoot. If you move the custom domain to connect to the site at Netlify, we will be happy to troubleshoot though.

If there are other questions or concerns, please let us know.

Hi Luke.
I have no custom domain, I’m just using Netlify’s default free domain.

Hi, @theninthsky. I do see that redirect working when I test:

$ curl -svo /dev/null https://flyingnotes.netlify.app/storybook  2>&1 | egrep '^< (HTTP|location)'
< HTTP/2 301
< location: /storybook/index.html
$ curl -svo /dev/null https://flyingnotes.netlify.app/storybook/index.html  2>&1 | egrep '^< (HTTP|location)'
< HTTP/2 200

There is a 301 redirect for the first rule which is how the rule is written. There is a 200 response for the second URL because there is a file at that location.

If you are expecting something different to occur, would you please let us know what that is?

That’s wierd, I see that it is working now.
Probably something I did wrong, thanks for your help!