0

I am using Google Cloud to set up a simple site but having a lot of issues with the app.yaml file.

All I need for now is: - Have the site always serve HTTPS - Have all non-www redirect to www - Have index.html be served at the root

I had a configuration that previously worked, then i tried tweaking it, but when i went to reset it... it no longer works. Only the homepage works and every link/url returns the homepage. This is the setup i had:

api_version: 1
threadsafe: true

handlers:
- url: /$
  secure: always
  redirect_http_response_code: 301
  static_files: www/index.html
  upload: www/index.html

- url: /(.*)
  static_files: www/\1
  upload: www/(.*)

Any suggestions appreciated!

  • how this isn't working? what error are you getting? where are you trying to dpeloy this, App Engine? if so please share with us the logs of running `gcloud app deploy --log-http --verbosity=debug` so we can see the actual error, also providing us with a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) would help to solve this much faster – Chris32 Jun 10 '20 at 23:27
  • The current error I am getting is that the whole site is working on the www and non-www versions e.g. https://www.example.co.uk - 200 OK https://example.co.uk - 200 OK www versions e.g. https://www.example.co.uk/link1 - 200 OK https://example.co.uk/link1 - 200 OK The logs are very long (hundreds of lines). Is there a particularly bit that needs sharing? There has been no error returned when i run gcloud app deploy. (I'm deploying it using Google Cloud SDK Shell) It's the actual online experience that is not what I was looking for. Thank you! – Alex Moran Jun 15 '20 at 09:01
  • This answer seems to be for redirecting from your appspot.com domain to your personal domain. I have managed to get that bit working, my issue is I now have two versions of the site live on the personal domain, the www and the non-www version – Alex Moran Jun 22 '20 at 08:20

1 Answers1

0

For mapping your domains, you can add and point your custom domains through the Custom Domains page by following the documentation here.

To redirect your requests, you can use wildcard mappings with services in App Engine by using the dispatch.yaml file. You can find instructions on how to do that here. If you would like to know more about routing requests, you can take a look at this documentation as well which also highlights creating a dispatch file.

Also you can see this stackoverflow answers.

Normally 200 OK means that there is no error.

Ahmad P
  • 134
  • 4