我使用Google App引擎上传了网页,并且运行正常。这是一个非常简单的网页,其中包含6个静态文件(全部为.html)
我需要从URL中删除.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
所有html文件都位于“网站”文件夹中,因此如何隐藏URL中的.html扩展名
所以请帮助我修复它。
答案 0 :(得分:0)
您可以尝试这样的操作,但是您不必依赖最后使用的现有全部捕获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
答案 1 :(得分:0)
如果只有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