Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Storage - Website Configuration Not Operating As Documented

GET requests to a subdirectory resolve to `index.html`, not a naked path like the documentation says. This is a significant limitation in terms of using Cloud Storage for static web hosting. My static website resolves to https://example.com/subdirectory/index.html, not https://example.com/subdirectory. In other words, when I navigate to https://example.com/subdirectory I get redirected to https://example.com/subdirectory/index.html. The bucket receives requests via the Global HTTTPS Load Balancer. Please advise.

https://cloud.google.com/storage/docs/gsutil/commands/web#description

1. The main_page_suffix applies to each subdirectory of the bucket. For example, with the main_page_suffix configured to be index.html, a GET request for http://www.example.com retrieves http://www.example.com/index.html but shows http://www.example.com as the URL to the requester, and a GET request for http://www.example.com/photos retrieves http://www.example.com/photos/index.html but shows http://www.example.com/photos as the URL to the requester.

 

Solved Solved
0 3 807
1 ACCEPTED SOLUTION

The fix for me was to switch to App Engine for website hosting. Cloud storage is fine for a static website provided there are no subdirectories because if there are you will not be able to get rid of the `.html` in the browsers URL bar. There may be a way to do it with URL rewrites but I was not able to find a timely solution.

I would like the "/index.html" to not be in the address bar of the browser. The documentation says it will not be, but it is.

"a GET request for http://www.example.com/photos retrieves http://www.example.com/photos/index.html but shows http://www.example.com/photos as the URL to the requester."

View solution in original post

3 REPLIES 3
Top Labels in this Space