I want to config domain to redirect to another domain in vercel. I have configured successfully but when I test with http. It redirect from http://sourcel_domain.com to https://source_domaim.com to https://destination_domain.com. How to configure to only redirect from http://sourcel_domain.com to https://destination_domain.com? Because of with current logic, I can’t verify the change address with Google Search Console
The domain troubleshooting guide can help with most custom domain configuration issues. You might be able to use that guide to solve it before a human is available to help you. Then you can come back here and share the answer for bonus points.
You can also use v0 to narrow down the possibilities.
Hi @viennguyen24hdev, welcome to the Vercel Community!
I understand your concern. The reason this is happening is because Vercel automatically upgrades HTTP requests to HTTPS for security reasons . This is why you’re seeing the intermediate redirect to https://source_domain.com
before the final redirect to the destination domain.
Have you tried creating this Redirect using the vercel.json
configuration:
{
"redirects": [
{
"source": "http://source_domain.com/:path*",
"destination": "https://destination_domain.com/:path*",
"statusCode": 301
}
]
}
I hope this was helpful.
Unfortunately this seems to return an error about the format:
Error: Redirect at index 0 has invalid
source pattern "http://source_domain.com/:path*".
Hi @bigsee, can you share your vercel.json
? Also, more details about your project and what are you trying to achieve here?
@anshumanb I am trying to fix issues flagged by the MXToolbox tool, similar to another unresolved post here. In short: I need http://my-domain to return 301
rather than 308
.
I don’t have a vercel.json
since the app is very basic, so I created one with your redirect snippet above. However, it seems that the suggested snippet triggers an error about the pattern being incorrect.
Hey, @bigsee! Could you try the following?
{
"redirects": [
{
"source": "/:path*",
"destination": "https://destination_domain.com/:path*",
"statusCode": 301
}
]
}
The issue is that in Anshuman’s vercel.json
, the source
property should only contain the pathname pattern without the protocol or domain.
Thank you, @pawlean! This unblocks the deployment issue, but unfortunately does not solve the issue. MXToolbox still reports a 308
response. (http://destination_domain.com =>
308
)
Woohoo! I’m glad that the vercel.json
configuration is now valid and working for path-based redirects.
Hmm, it could be a domain-level HTTP to HTTPS redirect that’s happening (which is why you’re seeing a 308 response) Where’s your domain hosted?
It’s worth checking to domain-level redirects (like changing from 308 to 301) by configuring this in the Vercel dashboard under your project’s domain settings.
See relevant guide: