Hosting: Simple rewrite from "/" to subfolder

2,000 views
Skip to first unread message

Peter LoBue

unread,
Apr 13, 2017, 1:47:30 AM4/13/17
to Firebase Google Group
I would like to host multiple "apps" with firebase hosting, and be able to change which one appears for the domain's root via hosting configuration rewrites.

My hosting folder looks like this:
/public
  /
app1
    index
.html
 
/app2
    index
.html
 
404.html
firebase
.json

firebase.json contents:
{
 
"hosting": {
   
"public": "public",
   
"rewrites": [
     
{ "source": "/", "destination": "/app1" }
   
]
 
}
}

Expected result:
I type example.com or example.com/ into my browser, and am presented with /app1/index.html

Current behavior:
I get the contents of 404.html

Thanks!

Michael Bleigh

unread,
Apr 13, 2017, 5:09:33 AM4/13/17
to Firebase Google Group

For this you should just alter public to be e.g. public/app1 for that. Rewrites are for serving a specific file for a URL pattern.


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c85c8f42-648b-4520-a7e2-502ebf8e2b84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter LoBue

unread,
Apr 13, 2017, 5:25:28 PM4/13/17
to Firebase Google Group
Thanks Michael, but I still want both /app1 and /app2 to remain available via the direct urls example.com/app1 and example.com/app2

Michael Bleigh

unread,
Apr 13, 2017, 5:33:25 PM4/13/17
to Firebase Google Group
Then you would want to do:

{"source":"/", "destination":"/app1/index.html"}

and you would need to make sure not to have /public/index.html (which would take priority over the rewrite).

Reply all
Reply to author
Forward
0 new messages