Search code examples
firebasegoogle-cloud-functionsfirebase-hosting

Redirect 301 in firebase


I have to do a 301 redirect from a domain with NO www to the one with www like:

example.com -> 301 -> www.example.com (same domain)

I've bee looking to this example in the official doumentation, but it seems like the configuration doesn't considerate the whole URL path, is there any way to accomplish this?

I'm thinking about creating a separate project for the domain without www and create a firebase cloud function that takes all requests and do a redirect from there

is that the way to go? any simpler solution?


Solution

  • You can redirect out f the box in firebase an option I haven't noticed you just go to the following options:

    • Hosting
    • Connect domain
    • You can write your domain like "example.com" without www
    • Select the Redirect check button
    • Write your redirect destination, in my case, is the same domain with www

    That's it!

    301-redirect-firebase