1

I have a PHP5.5 module created on Google Cloud's App Engine and a SQL module on Google Cloud SQL.

Here is my PHP app.yaml:

application: myapp
version: 1
runtime: php55
api_version: 1

handlers:
- url: /.*
  script: index.php

I am really new into Google Cloud, so I need to somehow create a subdomain such as subdomain.myapp.com and when my users try to access http://subdomain.myapp.com instead of http://myapp.com, I want the server to "give" them the /subdomain/index.php file instead of the /index.php file.

Andrebm
  • 13
  • 4

1 Answers1

2

Add both myapp.com and subdomain.myapp.com domains to your app in the developer console, see this Q&A: Google cloud DNS: point naked domain to www?

Add a subdomain module to your app which will serve your subdomain-specific files.

Add a dispatch.yaml file to dispatch requests based on the domain to their respective module, see this Q&A: AppEngine subdomains to modules without wildcard mapping

Note: if you use SSL and sessions with cross-domain navigation you'll need a wildcard certificate otherwise you'll encounter SSL errors.

You might be able to get away with a single module (lower instance uptime usage/costs) if you tolerate distinct paths in your urls, like this http://subdomain.myapp.com/subdomain/index.php - in your /index.php you'd need to parse the domain in the requested url and if it's a subdomain one then re-direct it to the distinct path instead. No dispatch file needed in this case. Not as clean as the other solution, IMHO.

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Could you please comment here how to do it step-by-step (menu by menu) about your **Add both myapp.com and subdomain.myapp.com domains to your app in the developer console** instruction? Thank you – Andrebm Jan 27 '16 at 18:11
  • check my answer to the post I mentioned, it has the pointer to the exact Google step-by-step procedure paying attention to the quoted details. Add `myapp.com` first, then repeat steps 2-5 (and 6 if not already done as in that post) for `subdomain.myapp.com` (`www` in that procedure corresponds to your `subdomain`). – Dan Cornilescu Jan 27 '16 at 18:25