Pointing 2nd custom domain to different URL (page) in my GAE app?

39 views
Skip to first unread message

Alex Kerr

unread,
Apr 21, 2016, 11:19:18 AM4/21/16
to Google App Engine
Hi,

I have a custom domain set up for my GAE app (PHP) and want to add a 2nd custom domain that points to a different homepage - so to the user appears to be a separate site. I don't want to create a whole new app as the two sites need to partially share Datastore and Cloud Storage backend.

Adding a second custom domain appears to be easy in the Cloud Dashboard settings, so I just need a way to point it to myapp.appspot.com/second-home-page.html rather than just myapp.appspot.com/ (which my first custom domain does of course).

Many thanks,
Alex

Mihail Russu

unread,
Apr 21, 2016, 11:23:16 AM4/21/16
to Google App Engine
On your incoming requests in your PHP code check what hostname the request came to and depending on that decide what page to render...

Alex Kerr

unread,
Apr 21, 2016, 11:46:22 AM4/21/16
to Google App Engine
That's a good idea, thanks, but although I'm using PHP on the backend via AJAX, my pages are actually all static (and in fact it's mostly a single page app with different views contained in one HTML and JS file) and served by CDN so I'm wondering if there's another way that doesn't rely on server-side processing...

Thanks

Mihail Russu

unread,
Apr 21, 2016, 12:04:08 PM4/21/16
to Google App Engine
Try creating a new module within your app and redirecting requests matching the host you need to that new module via dispatch.yaml, i.e.:

- url: "custom_domain_2.example.com/*"
 
module: module-for-custom-domain-2
Reply all
Reply to author
Forward
0 new messages