Normally i would do it with .htaccess
but django doesn't have it.
So what is the best way and what is the code for it to redirect from www.olddomain.com to www.newdomain.com?
NOTE: we are not using Apache, but Gunicorn
thanx!
The best way to do this is still with your web server rather than Django. This will be much quicker and more efficient than doing it with Django.
Check out this question for more info.
UPDATE
If you really want to do it within django then edit your url conf file (which manages django's url dispatcher) to include the following at the top -
from django.views.generic.simple import redirect_to
urlpatterns = patterns('',
(r'^.*$', redirect_to, {'url': 'http://www.newdomain.com'}),
)
For more info check out the documentation.
import urlparse
from django.http import HttpResponseRedirect
domain = request.GET['domain']
destination = reverse('variable_response',args=['Successful'])
full_address = urlparse.urljoin(domain, destination)
return HttpResponseRedirect(full_address)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With