【发布时间】:2014-02-25 15:06:14
【问题描述】:
我想根据查询参数提供静态文件。更具体地说,我想为搜索引擎优化提供预渲染快照。这些页面托管在 Google Appengine 上,所以我使用 app.yaml 来定义这些 url。
handlers:
# Consider anything matching a dot static content.
- url: /(.*\..*)$
static_files: dist/\1
upload: dist/(.*\..*)$
# Serve snapshots for seo
- url: /?_escaped_fragment_=(.*)
static_files: dist/snapshots/\1
upload: dist/(.*)$
# Otherwise let Angular handle it.
- url: /(.*)
static_files: dist/index.html
upload: dist/index.html
但是,当我使用查询参数_escaped_fragment_ 获取 url 时,会触发最后一个 url 处理程序。是否可以在 url 中定义查询参数?如果是这样,我做错了什么?
【问题讨论】:
-
您要获取的网址是什么?
-
任何 url googlebot 都会获取。例如我定义了
/support,所以googlebot 会获取/?_escaped_fragment_=support。这是一个 AngularJS 站点,所以/?_escaped_fragment_=support应该获取一个预渲染的 html 文件以便对其进行索引。 -
解决方法是创建一个处理程序,它要么返回 dist/index.html(当 escape_fragment 不在查询字符串中时),否则返回给定 的 snapshop html转义片段。我不知道以这种方式提供服务需要多少额外费用。
标签: python google-app-engine app.yaml