쿼리 매개 변수에 따라 정적 파일을 제공하고 싶습니다. 보다 구체적으로는 검색 엔진 최적화를 위해 사전 렌더링 된 스냅 샷을 제공하고 싶습니다. 페이지는 Google Appengine에서 호스팅되므로 app.yaml을 사용하여 이러한 URL을 정의합니다.Google Appengine의 app.yaml에서 쿼리 매개 변수를 정의하십시오.
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
그러나, 나는 마지막 URL 핸들러가 트리거되는 쿼리 매개 변수 _escaped_fragment_
로 URL을 가져올 때. URL에서 검색어 매개 변수를 정의 할 수 있습니까? 그렇다면, 내가 뭘 잘못하고 있니?
가져 오려는 URL이 무엇입니까? – marcadian
url googlebot이 가져올 것입니다. 예를 들어'/ support'가 정의되어 있으므로 googlebot은'/? _ escaped_fragment_ = support'를 가져옵니다. 이것은 AngularJS 사이트이므로'/? _ escaped_fragment_ = support'는 미리 렌더링 된 html 파일을 색인화하기 위해 그것을 가져와야합니다. –
해결 방법은 _escape_fragment_가 쿼리 문자열에없는 경우 dist/index.html을 반환하는 핸들러를 생성하고 else는 주어진 _escape_fragment_에 대해 snapshop html을 반환합니다. 이런 식으로 서비스하는 데 추가 비용이 얼마나되는지는 알지 못합니다. –