Hi everyone,
I’m encountering an issue with a rewrite rule in my Vercel project that I could use some help with. Here’s the situation:
I have the following rewrite rule in my vercel.json:
{ "rewrites": [ { "source": "/shop/:nameAndId", "destination": "/product" } ] }
Problem:
The intention of this rule is to rewrite URLs like https://mydomain.com/shop/fibroid-fertility-tea-10 to https://mydomain.com/product/fibroid-fertility-tea-10. However, after applying this rule, I noticed that all files and assets under the /shop/ path (such as HTML files, images, and other resources) are being affected by this rewrite.
For example:
- URLs like
https://mydomain.com/shop/somefile.htmlorhttps://mydomain.com/shop/image.pngare also getting redirected to/product/somefile.htmland/product/image.pngrespectively, which is not the desired behavior.
Question:
How can I configure the rewrite rule so that only URLs matching the /shop/:nameAndId pattern are rewritten to /product/:nameAndId without affecting other files and resources under the /shop/ path?
Is there a way to exclude certain files or directories from this rewrite or to make the rule more specific so it doesn't interfere with my static assets?
Any help or guidance would be greatly appreciated!
Thanks!

