Using placeholder or wildcard to add directory to redirects path

I am using a _redirects file in a static folder of my gatsby build (the static folder makes sure that the _redirects file ends up in my final build directory so Netlify can access).

I’ve got a number of blog articles on my site that have the following path characteristics:

I would like to use a splat or wildcard sort of operator to turn the above URLs into this:

I want to put /blog/ as a directory path before my posts

Is this possible? I’m looking at the * and :splat operators but it doesn’t seem to apply to my situation.

How would I do this?


Hi @songfarm-david,

From looking at the docs it looks like it could work, I really haven’t tested it, just trying to help:

/*    /blog/:splat

And if for some reason the path exists this would be a case of “shadowing” and you can force it by adding a 200!

/*    /blog/:splat 200!

Hope it helps

1 Like

I agree with @jcespinoza. That solution should work. :+1: Another possible solution is to just put your blog posts in a folder named blog/ in your publish directory. Either way should get you there. :slight_smile:

Hey thanks for the reply. Would this not also affect /contact-us or /about as well? How not?


So I got around it by adding the string /blog to the path in my gatsby-node.js (I should have mentioned I was creating these posts programmatically). Thanks for the help and tips @Dennis and @jcespinoza.

1 Like