如何从Google Cloud Platform URL删除.html扩展名 [英] How to remove .html extensions from Google Cloud Platform URL

查看:103
本文介绍了如何从Google Cloud Platform URL删除.html扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Cloud Platform托管静态网站.我不知道如何从URL中删除.html文件扩展名.理想情况下,我希望自己的网址读为" https://www.website.com/index "

I am hosting a static website with the Google Cloud Platform. I can't figure out how to remove the .html file extension from the URL. Ideally, I would like to have my url read "https://www.website.com/index"

我尝试使用.htaccess文件,但没有任何运气.我见过有人在谈论使用名为"app.yaml"的文件,但我仍然感到困惑.

I have tried using .htaccess files, but have not had any luck. I have seen people talking about using a file called "app.yaml", but I am still confused.

从Google Cloud Platform URL删除.html文件扩展名的最佳方法是什么?

What is the best way to remove the .html file extension from a Google Cloud Platform URL?

推荐答案

我了解您要删除网站导航中找到的链接中的.html扩展名.

I understand you want to remove the .html extension in the links found in the navigation of your site.

将文件作为html(删除扩展文件后)的方式是将文件的Content-Type元数据设置为"text/html".

The way for you to serve the files as html (after removing the extension file) is to set the file's Content-Type metadata to "text/html".

例如,在控制台">存储桶"中,有一个"contact.html"文件,请执行以下步骤:

For example in your Console > Bucket there's a "contact.html" file, perform the following steps:

  1. 单击列表最右边的三个点.
  2. 选择重命名"选项,然后将文件重命名为联系人".
  3. 再次单击三个点,然后选择编辑元数据"选项.
  4. 在表单中,您应该看到内容类型"字段-输入text/html.
  5. 保存更改.

访问/contact链接/URL时,即使删除了.html扩展名,该文件现在仍应以HTML格式提供.

When accessing /contact link/URL, the file should now be served as HTML even after removing the .html extension.

这篇关于如何从Google Cloud Platform URL删除.html扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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