301 redirects - no compelling solution?

181 views
Skip to first unread message

Alistair Burrowes

unread,
Sep 28, 2015, 9:58:37 PM9/28/15
to Google App Engine
Hi,

It seems like there is no good solution for setting up 301 redirects at a domain level which is a common requirement of websites and should not need to be handled by an instance. Existing options seem to be:
  • Use modules and route via dispatch non-canonical domains. This doesn't appear to handle the case where you want to redirect http to https for the canonical domain as I don't think you can use http vs https for module routing. The solution in general also kind of sucks because you rack up instance hours for a pretty trivial requirement.
  • Pass all requests through some handler and check the domain etc. Not bad for dynamic content, but static requests don't hit your app engine instance and you would need to force them to do so (avoiding the static content cdn) and have some ugly code that manually returns the static resource if the domain/scheme is all good.
  • Have a separate cloud project that non-canonical domains are pointed to that just redirects requests. This is fine, however doesn't work in the case that you want to redirect http to https since both must point to the same cloud project.
I would like a more PaaS option such as:
  • Simple 301 redirects possible via a configuration file
  • Simple 301 redirects possible via the cloud console
Am I missing something? If not can a more PaaS option be provided?

Luna Duclos

unread,
Sep 29, 2015, 3:58:43 AM9/29/15
to google-a...@googlegroups.com
In your app.yaml, you can use  "secure: always" to force the app to use https, this will redirect any and all requests to https without them hitting your app's code at all, does this seem what you're looking for ?

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/833c4de0-9406-432d-8e67-d2e7a4b0715c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alistair Burrowes

unread,
Sep 29, 2015, 4:10:34 AM9/29/15
to Google App Engine
Thanks I wasn't aware of that and that is really good to know. I will use that when my site moves to https.

However, I still think a PaaS style option should be available for domain redirects. Perhaps in app.yaml as well. I think i'll create an issue in the app engine issues tracker.

Michael Safyan

unread,
Dec 31, 2015, 4:54:23 AM12/31/15
to Google App Engine
Have there been any updates since? I'm finding myself wanting to both do a scheme and domain redirect (force HTTPS, always include or always omit the "www." prefix for the canonical domain). Because of this lack, I'm finding myself duplicating the same "BaseHandler" over and over again, and it's pretty ugly (since I don't want to do a sequence of redirects, but rather a single redirect that combines both).

Anthony Shapley

unread,
Jan 1, 2016, 6:51:44 AM1/1/16
to Google App Engine
This is very true, but it uses a 302 redirect instead of a 301 - it really isn't the right option for people looking to make a permanent move.
Reply all
Reply to author
Forward
0 new messages