Skip to content

Commit

Permalink
redirect old master/slave alias
Browse files Browse the repository at this point in the history
  • Loading branch information
systempuntoout committed May 2, 2012
1 parent 48f0935 commit 1b315f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
HOST = "www.gaecupboard.com" #Insert your host here: foo.appspot.com or in case of custom domain www.foo.com
REDIRECT_FROM_APPENGINE_HOST_TO_HOST = True
APPENGINE_HOST = "gaecupboard-hrd.appspot.com" #Mandatory if REDIRECT_FROM_APPENGINE_HOST_TO_HOST is set to True

APPENGINE_HOST_OLDMS = "gaecupboard.appspot.com" #In case you've migrated from MS
ABOUT =u"""
GAE Cupboard is a five days hack project made after a meniscus surgery ([buckethandle](http://www.leadingmd.com/patientEd/assets/buckethandle_tear.gif "buckethandle")).
Having some time to spare, I've tried to implement something to store and organize part of the public knowledge around Google App Engine.
Expand Down
6 changes: 5 additions & 1 deletion application.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ def internalerror():
def redirect_from_appspot(wsgi_app):
"""Handle redirect to my domain if called from appspot (and not SSL)"""
from_server = APPENGINE_HOST
try:
from_server_migrated = APPENGINE_HOST_OLDMS
except:
from_server_migrated = ' '
to_server = HOST

def redirect_if_needed(env, start_response):
if REDIRECT_FROM_APPENGINE_HOST_TO_HOST and env["HTTP_HOST"].endswith(from_server) and env.get("HTTPS") == "off":
if REDIRECT_FROM_APPENGINE_HOST_TO_HOST and (env["HTTP_HOST"].endswith(from_server) or env["HTTP_HOST"].endswith(from_server_migrated) ) and env.get("HTTPS") == "off":
# Parse the URL
request = webob.Request(env)
scheme, netloc, path, query, fragment = urlparse.urlsplit(request.url)
Expand Down

0 comments on commit 1b315f3

Please sign in to comment.