Redirect to Firebase Hosting custom domain

前端 未结 3 1376
南笙
南笙 2020-12-03 05:10

I have setup a custom domain with Firebase Hosting (eg. myapp.domain.com).

How can one redirect (or turn off) the default Firebase Hosting URL (eg. myapp.firebaseap

3条回答
  •  -上瘾入骨i
    2020-12-03 06:11

    In addition to specifying canonical link as mentioned in Frank van Puffelen's answer. We can also add front end JavaScript code to do the actual redirect like this without disclosing default url.

    if (location.hostname.indexOf('custom.url') === -1) {
        location.replace("https://custom.url");
    }
    

提交回复
热议问题