Home > Software engineering >  Firebase hosting - redirect from one custom domain url to another custom domain
Firebase hosting - redirect from one custom domain url to another custom domain

Time:07-11

Is it possible to re-direct from a old custom domain url to another customer domain url as a configuration in the firebase.json hosting? Here is what I am trying to do. When the user hits https:\\oldurlofmyapp.com, I should redirect them to https:\\newurlofmyapp.com.

      "redirects": [
        {
          "source": "https://oldurlofmyapp.com",
          "destination": "https://newurlofmyapp.com",
          "type": 301
        }
      ]

Note: The old custom domain is expired so can't verify the old custom domain anymore.

CodePudding user response:

No unfortunately.

And it's not peculiar to Firebase but it is to all Hosting configurations. Any given hosting configuration, configures for a particular domain name. So redirects are usually within the domain and would be based on routes (relative to that domain).

Even if you were to do such redirection, you would instead use the catch-all wildcard and do something like the following:

"redirects": [
   {
      "source": "**",
      "destination": "https://newurlofmyapp.com",
      "type": 301
    }
]

But this technically won't work. It won't work because the website is not showing on the old domain again in the first place, so there's no way to redirect on valid visits. Like Firebase is no longer in charge of the hosting on that domain you see.

If you've lost access to old custom domain, you technically can't issue a redirection on it from anywhere. You can't redirect in Firebase because the DNS records you set will no longer be working (I mean that's why you are having the need to redirect in the first place). You can't redirect from the domain registrar for the very fact that you've lost the domain.

And if you didn't lose access to the old domain and needed to do such redirection; you won't be needing to do it in firebase.json file. You would have directly handled this either by adding the new domain to the hosting dashboard in the Firebase console and making the old domain to redirect to the new domain there from the console. Or by adding the new domain to Firebase console and setting the domain-wide redirection but from the domain registrar (or DNS records) yourself.

Guess your solution would be to broadcast to your users in some way to start using the new domain as you've lost the old one.

And hey sorry about this, I've once been here and it hurts deeply. In our case, we knew the domain was expiring but couldn't renew because we forgot password of the Gmail we used in creating the account that was used to buy the domain. Recovery from Google and the domain registrar were futile. And that was it.

Cheers!

  • Related