简体   繁体   中英

How to configure Firebase Hosting to serve my app from my custom domain with and without the "www" subdomain?

I want my website to be accessible from: www.myexamplewebsite.pt AND myexample.pt . With and without the www part.

Right now only www.myexamplewebsite.pt is working.

When I try to access myexamplewebsite.pt (without www ) this happens:

    1. I get a Warning: Potential Security Risk Ahead page
    1. And even if I choose to proceed on the Warning page, I get a page not found from Firebase like this one:

在此处输入图片说明


  • Here is my current Hosting config for my Custom Domain:

在此处输入图片说明


  • And here is a DNS CNAME record I have on my DNS provider.

Note: Since I'm getting a page not found from Firebase (as mentioned above), I guess that there's nothing wrong with my DNS settings.

在此处输入图片说明


QUESTION

How can my web app be accessible from both URLs (with and without the www ) ?

The only piece of Firebase Hosting doc that I found that mentions this, didn't help me very much:

https://firebase.google.com/docs/hosting/custom-domain#set-up

在此处输入图片说明

UPDATE: Here is my DNS config:

在此处输入图片说明

In my experience, creating the DNS A records for both the domains (ie www.myexamplewebsite.pt and myexamplewebsite.pt in your case) does the trick. See https://firebase.google.com/docs/hosting/custom-domain#go-live for the doc on DNS A records creation.

Now it's working.

1 - I've added my 1st custom domain. I think I've entered it without the www (almost sure)

2 - Somehow, after it's been connected (detected the DNS records), it was displayed on Firebase Hosting with the www (it's the last one in the second picture below)

3 - Then I've added a new custom domain. Again, this time for sure I've entered it without www and marked to redirect to my domain with the www

Result: Not my app is accessible with and without the www


DNS Config

在此处输入图片说明

Firebase Hosting Domains:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM