1

It seems Google has managed to spider some of my heroku apps pages on the app sub domain i.e. myapp.herokuapp.com. I need to do a 301 redirect so all these pages point to the actual apps domain www.myapp.com

Any idea how I do this in Django? I see the redirect app only works for 404s so this won't be any good, and all the examples for RedirectView are for the domain path.

KingFu
  • 1,358
  • 5
  • 22
  • 42
  • possible duplicate of [Heroku how to redirect http:// to http://www](http://stackoverflow.com/questions/5389575/heroku-how-to-redirect-http-to-http-www) – Alasdair Oct 21 '13 at 18:32

1 Answers1

3

You could use the Django Hostname redirects app and its middleware.

Thomas Orozco
  • 53,284
  • 11
  • 113
  • 116
  • This worked for me, but I needed to patch https://github.com/MidwestCommunications/django-hostname-redirects/blob/master/hostname_redirects/middleware.py to use request.META['HTTP_HOST'] instead of request.META['SERVER_NAME'] – the server name is always set to "0.0.0.0" on Heroku. – arexx Mar 13 '15 at 21:10