I'm trying to permanently redirect a legacy root URL to the new location in Django (hosted on Red Hat Openshift).
I've tried this solution but can't get it to work (even if the simplest case of http and without a further path). I'm not experienced with wsgi as you can probably guess and all help is very appreciated.
Here's my attempt to edit the last part of wsgi.py (redirecting from www.olddomain.com to www.newdomain.com). When I try to deploy it, trying to reach www.olddomain.com results in a error ("Can't reach this page"):
...
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()
def application(environ, start_response):
if environ['HTTP_HOST'][:17] == 'www.olddomain.com':
start_response('301 Redirect', [('Location', 'http://www.newdomain.com/'),])
return []
return _application(environ, start_response)
Thank you for your help