#Top level redirects not working
1 messages · Page 1 of 1 (latest)
Based on the knowledge sources provided, it seems that your configuration for redirects is correct. However, there are a few things you might want to check:
-
Make sure that your
next.config.jsorvercel.jsonfile is correctly set up and that you have redeployed your application after making changes. Source (https://vercel.com/guides/can-i-redirect-from-a-subdomain-to-a-subpath) -
There might be an issue with the way you're using the
hasfield. In the example provided (https://vercel.com/guides/can-i-redirect-from-a-subdomain-to-a-subpath), thehasfield is used to check if the host is a specific value. In your case, you're checking if the host is "marketplace-dev.thehomemag.com". If the host is not exactly this value, the redirect might not work. -
There could be an issue with the order of your redirect rules. In Next.js, the order of redirect rules matters. The first rule that matches a given path is the one that will be applied. If you have other redirect rules above these ones that are also matching these paths, they might be applied instead. Source (https://github.com/vercel/next.js/issues/47516)
If none of these suggestions work, it might be helpful to provide more information about your setup or consider opening an issue on the Next.js GitHub repository.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@sinful turtle kapa.ai is still learning and improving, please let us know how it did by reacting below
@woeful iron the second rewrite works, the first doesnt. its reroutign the homepage. is it overwritten by the second rewrite, which rewrites each subpage?
Let me check the knowledge base for you. One moment! :books:
The issue you're experiencing might be due to the order of your rewrite rules. In Next.js, the order of rewrite rules matters. The first rule that matches a given path is the one that will be applied.
In your case, the second rule /:path* is a catch-all route that matches any path, including the root /. So, if the second rule is placed before the first one, it will match the root path and the first rule will never be applied.
To fix this, you should place the more specific rule (the root /) before the more general rule (the catch-all /:path*). Here's how you can adjust your rules:
[
{
"source": "/",
"has": [{ "type": "host", "value": "marketplace-dev.thehomemag.com" }],
"destination": "<https://dev.askhomey.com",>
"permanent": true
},
{
"source": "/:path*",
"has": [{ "type": "host", "value": "(www.)?marketplace-dev.thehomemag.com" }],
"destination": "<https://dev.askhomey.com/:path*",>
"permanent": true
}
]