首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在谷歌应用程序引擎中隐藏.html扩展名(云主机)

如何在谷歌应用程序引擎中隐藏.html扩展名(云主机)
EN

Stack Overflow用户
提问于 2018-07-23 02:14:08
回答 2查看 810关注 0票数 1

我使用谷歌应用程序引擎上传了我的网页,它工作得很好。这是一个非常简单的网页与6个静态文件(.html所有)

我需要从网址中删除.html扩展名。例如:我有www.example.com/contact.html,我想要www.example.com/contact

我当前的app.yaml是

代码语言:javascript
复制
runtime: php55
api_version: 1
threadsafe: true

handlers:
- url: /
  static_files: website/index.html
  upload: website/index.html

- url: /
  static_dir: website

所有的网页文件都在"Website“文件夹内,如何才能隐藏.html扩展名

所以请帮我把它修好。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-07-24 23:16:58

如果你只有6个静态文件,并且你不想使用.htaccess,你必须这样做:

而不是

代码语言:javascript
复制
> handlers:
> 
> - url: /   static_dir: website

您可以:

代码语言:javascript
复制
handlers:

- url: /
  static_files: website/index.html
  upload: website/index.html

- url: /file1
  static_files: website/file1.html
  upload: website/file1.html

- url: /file2
  static_files: website/file2.html
  upload: website/file2.html

- url: /file3
  static_files: website/what_ever_name.what_ever_format
  upload: website/what_ever_name.what_ever_format
票数 2
EN

Stack Overflow用户

发布于 2018-07-23 03:02:21

您可以尝试这样的操作,但是您必须不依赖于您在最后拥有的现有的通用static_dir处理程序,因为由于新的通用处理程序使用.html扩展名扩展了任何其他文件模式,所以它永远不会实现:

代码语言:javascript
复制
handlers:
- url: /
  static_files: website/index.html
  upload: website/index.html

# handler for specifically requested .html files
- url: /(.*\.html)$
  static_files: website/\1
  upload: website/.*\.html$

# add any other more specific file patterns here, before the catch-all case below

# catch-all handler implicitly serving .html files, no handler below it will be reached
- url: /(.*)$
  static_files: website/\1.html
  upload: website/.*\.html$

# no other handler from this point forward will be reached

附注:static_dirstatic_files的重叠处理程序url模式可能会导致问题,请参阅Static files are missing

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51467971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档