Search code examples
google-app-engineyaml

How to configure Google App Engine app.yaml file to force https


How do I force all domain.tld and www.domain.tld to https://domain.tld? I was able to get close. If I uncomment by commented lines it will force everything but then everything in my static folder can't be accessed.

runtime: php74
env: standard
entrypoint: serve public/index.php

handlers:

#- url: /.*
#  script: auto
#  secure: always
#  redirect_http_response_code: 301

- url: /static
  static_dir: static

Solution

  • You need this:

    runtime: php74
    env: standard
    entrypoint: serve public/index.php
    
    handlers:
    
    - url: /static
      static_dir: static
    
    - url: /.*
      script: auto
      secure: always
      redirect_http_response_code: 301
    

    The order is important because the first matching rule is used.