Can't figure out how to have website point to

2019-07-26 21:30发布

问题:

So I'm almost finished with getting my website up. I've created the correct bucket (www.samuraifish.com), but for some reason when I try to get the public link it's https://storage.googleapis.com/www.samuraifish.com/htdocs/index.html instead of www.samuraifish.com. When I click on "Edit Website Configuration" I get a note that says "You can access this website at www.samuraifish.com", but when I type in www.samuraifish.com in the browser I get the following:

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>

How do I fix this? I have already created my CNAME through Google Domains, so www.samuraifish.com should point to c.googleapis.com.

Thanks, Priya

回答1:

To display a specific page when only a directory URL is requested (which is the case for a request to the domain-only www.samuraifish.com URL) you need to assign an index page.

From Optional: Assigning index and error pages:

An index page (also called a webserver directory index) is the file returned to visitors to your static site who request a "directory". If the top level site, such as http://www.example.com, is requested, or a missing page is requested, e.g., http://www.example.com/directory, the service attempts to return an index page. If you haven't assigned an index page suffix, or if the "directory" doesn't have an associated index page, Cloud Storage returns an error page. The property that controls which file acts as the index page is MainPageSuffix.

For example, if the MainPageSuffix is index.html, Cloud Storage attempts to return the object www.example.com/index.html when a user requests http://www.example.com. Similarly, if there is no object www.example.com/directory, then Cloud Storage attempts to return the object www.example.com/directory/index.html when a user requests http://www.example.com/directory. If there is no such object, Cloud Storage returns an error page.