Subdomain can't be redirected to subpath

I config a subdomain to my project. I want to redirect the subdomain (markdown-syntax-hub.tcblabber.cn) to a subpath (tcblabber.cn/markdown-syntax-hub).

I added vercel.json in the docs folder following the blogs and the community discussion below:

But the settings doesn’t work. My site URL are still https://markdown-syntax-hub.tcblabber.cn/.

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 @docsimpo, welcome to the Vercel Community!

It seems like the vercel.json file has rewrites configured instead of redirects.

The following vercel.json will redirect all paths from https://markdown-syntax-hub.tcblabber.cn/ to https://tcblabber.cn/markdown-syntax-hub. Can you add it to the project using the subdomain?

{
  "trailingSlash": true,
  "redirects": [
    {
      "source": "/(.*)",
      "destination": "https://tcblabber.cn/markdown-syntax-hub"
    }
  ]  
}

Hello @anshumanb, thanks for your reply!

I added the code snippet redirects above to vercel.json. It redirects the URL to the subpath designated in destination, but causes a 404: Not_Found error.

Hi @docsimpo, thanks for sharing your outcome. I just tried it myself for one of my projects and the redirect worked fine. The only difference is the trailingSlash in the config. Are you using specifically for some reason? If not can you try removing it?