Hello,
I’m currently facing an issue with setting up conditional redirects in my netlify.toml
file. I have two domains, customdomain.com
and maindomain.com
, and I want to serve different content for each domain.
Here’s my current netlify.toml
configuration:
[[redirects]]
from = "/*"
to = "/custompage/:splat"
status = 200
force = true
conditions = {{ Host = ["customdomain.com"] }}
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
force = true
conditions = {{ Host = ["maindomain.com"] }}
With this configuration, I expect all requests to customdomain.com
to be rewritten to /custompage/:splat
and all requests to maindomain.com
to be rewritten to /index.html
.
However, I’m experiencing some unexpected behavior. When I check my deploy logs, I see the following message:
You have the following Netlify rewrites that might cause conflicts with the Next.js Runtime:
/* /custompage 200
/* /index.html 200
I’ve checked my next.config.js
file and confirmed that there are no redirects or rewrites that could be conflicting with my Netlify rewrites.
Then on second attempt, I’ve applied this in netlify.toml lead no redirects (i.e. it renders maindomain.com):
[[redirects]]
from = "https://www.customdomain.com"
to = "/custompage"
status = 200
force = true
error:
8:53:06 PM: You have the following Netlify rewrite that might cause conflicts with the Next.js Runtime:
8:53:06 PM:
8:53:06 PM: - https://customdomain.com /custompage 200
8:53:06 PM:
8:53:06 PM: For more information, see https://ntl.fyi/next-rewrites
On third attempt I’ve used the _redirects file
https://www.customdomain.com /custompage 200!
No luck either:
error:
7:59:55 PM: You have the following Netlify rewrite that might cause conflicts with the Next.js Runtime:
7:59:55 PM:
7:59:55 PM: - https://www.customdomain.com /custompage 200
7:59:55 PM:
7:59:55 PM: For more information, see https://ntl.fyi/next-rewrites
and no redirects (i.e. it renders maindomain.com)
I would appreciate any help or guidance on how to correctly set up these conditional redirects.
Thank you!
My site is https://localization-hq.netlify.app