GCP - 静态托管 - 重定向到/index.html [英] GCP - Static hosting - Redirects to /index.html

查看:85
本文介绍了GCP - 静态托管 - 重定向到/index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 GCP 和 Google Cloud Storage 为静态网站提供服务.我已完成此处指定的所有内容 https://cloud.google.com/storage/docs/hosting-static-website

I'm trying to serve a static website using GCP and Google Cloud Storage. I have done everything specified here https://cloud.google.com/storage/docs/hosting-static-website

假设我有以下文件结构:

Say I have the following file structure:

- index.html
- folder
    - index.html
    - another.html

我输入 www.example.com/folder.

它重定向到 www.example.com/folder/index.html => index.html 是不受欢迎的

It redirects to www.example.com/folder/index.html => index.html is undesired

但如果我输入 www.example.com/folder/,它不会重定向并透明地正确提供 index.html 页面.

But if I enter www.example.com/folder/, it doesn't redirect and serves correctly the index.html page transparently.

如何防止第一种行为?还是自动添加尾部斜杠?

How do I prevent the first behavior? Or automatically add a trailing slash?

谢谢!

推荐答案

Firebase Hosting 可能比使用存储桶更容易,因为可以在那里定义重写规则.

Firebase Hosting might be easier than using a bucket, because one can define rewrite rules there.

这篇关于GCP - 静态托管 - 重定向到/index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆