Django - redirect to version from www

Is there a simple way in Django to redirect everything from a non-www domain to the version with it? I mean from http://example.com to http://www.example.com.

+8
redirect python django dns
source share
3 answers
+14
source share

How to say docs

If PREPEND_WWW is True, URLs that do not have a leading "www." will be redirected to the same URL with the leading "www."

By default, PREPEND_WWW set to False . You can change this value to True in the settings.

 PREPEND_WWW = True 

To do this, you must enable CommonMiddleware in your resellers.

 MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', ) 
+6
source share

You can also skip the prefix through the correct DNS configuration.

+1
source share

All Articles