我使用谷歌应用程序引擎上传了我的网页,它工作得很好。这是一个非常简单的网页与6个静态文件(.html所有)
我需要从网址中删除.html扩展名。例如:我有www.example.com/contact.html,我想要www.example.com/contact
我当前的app.yaml是
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: website/index.html
upload: website/index.html
- url: /
static_dir: website
所有的网页文件都在"Website“文件夹内,如何才能隐藏.html扩展名
所以请帮我把它修好。
发布于 2018-07-24 23:16:58
如果你只有6个静态文件,并且你不想使用.htaccess,你必须这样做:
而不是
> handlers:
>
> - url: / static_dir: website
您可以:
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
发布于 2018-07-23 03:02:21
您可以尝试这样的操作,但是您必须不依赖于您在最后拥有的现有的通用static_dir
处理程序,因为由于新的通用处理程序使用.html
扩展名扩展了任何其他文件模式,所以它永远不会实现:
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_dir
和static_files
的重叠处理程序url模式可能会导致问题,请参阅Static files are missing
https://stackoverflow.com/questions/51467971
复制相似问题