Redirect on the root domain doesn't work

PLEASE help us help you by writing a good post!

  • we need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot

The better the post - the faster the answer.

I would like to setup a permanent redirect on the root URL of my project. So, this address - https://jarmos.netlify.app should redirect to https://jarmos.vercel.app. Is this even achievable?

I tried configuring the netlify.toml file of my project with the following entries:

[[redirects]]
from = "https://jarmos.netlify.app"
to = "https://jarmos.vercel.app"
status = 301
force = true

Hi, @Jarmos-san. The rule is written correctly and it would work … if it was active but it is not.

This site has had its production deploy locked. So, the redirect rule isn’t working on the production site because your production site is locked to an old version where that redirect does not exist.

To resolve this you can do one of two things (whichever you prefer). First, you can unlock deploys to start auto-publishing again and then trigger a new deploy. Alternatively, you can manually publish the newer deploys in our web UI (or via API call).

To summarize, the rule is correct but the deploy that contains it isn’t currently the production deploy. If you publish a deploy with the redirect, it will start working and there are (at least) two ways to do that.

By the way, it might help to also make a second rule which will redirect URLs like:

https://jarmos.netlify.app/blog/post-1

To:

https://jarmos. vercel.app/blog/post-1

This would 301 redirect and pass the path along to the new site. That redirect rule would look like this:

[[redirects]]
  from = "https://jarmos.netlify.app/*"
  to = "https://jarmos.vercel.app/:splat"
  force = true
  status = 301

That is optional but I though you might find it useful. If there are questions about this issue or if either solution above does not work, please let us know.

1 Like

Hi Luke, thanks for sharing a detailed solution to the issue I was facing!

And yes, you were right I did lock auto publishing on Netlify since I was using GitHub Actions for building & deploying the website.

1 Like