Rewrite all paths after slash to a page

Hi! I have a gatsby site. I want to make it so any url with relative path /share/* goes to the page defined at /share. I want the url to be preserved in the user’s address bar.

E.g. if I go to, I want the page at to be served - but I want the address browser to still have the url

I though this redirect rule in _redirects file should do it:

/share/* /share 200

But it doesn’t work - it just does a normal redirect to /share, and anything after the final slash is lost.


My site url (on a branch deploy to test this out):

Hey @alexm,
Could you try adding a ! after 200, to force the rewrite? So: /share/* /share 200!

thanks @jen! tried that but still didn’t work - it changes the url in the address bar like a normal redirect.

the rewrite masking works if I rewrite to an external url - but not to an internal relative path.

e.g. -

does not work (changes url in bowser):
/share/* /shareGDO 200!

does work:
/share2/* 200!

Hey @alexm,
Hmmm I just tested this here: and it seems to be working, unless I’m misunderstanding what you’re trying to do.

For the above, the redirect rule is /my-name/* to /my-name with forced 200 status. I have a my-name.html file that’s redirected to, regardless of what’s after /my-name/, and this setup retains the original path in the URL bar.

Since you were able to get your second rule to work, your redirects are obviously being uploaded- so that’s not the issue. The other things I can think of would be:
we process the redirect rules from top to bottom in the redirects file, so we recommend going most specific to least specific. Maybe another rule is being processed before the one you want?

And the other thing to confirm is that you have a page called shareGDO.html to redirect to?