[Fixed]-Django – redirect to version with www

16👍

👤yetty

11👍

As docs say

If PREPEND_WWW is True, URLs that lack a leading “www.” will be redirected to the same URL with a leading “www.”

By default PREPEND_WWW is set to False. You can change that to True in settings.

PREPEND_WWW = True

To make this work, You have to include CommonMiddleware in Your middlewares

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
)

1👍

You can also skip prefix via proper DNS configuration.

👤erg

Leave a comment