Skip to main content

How to manage redirects in Aldryn Django applications

See Also

Protocol redirects

Divio applications are HTTPS-ready by default, and we provide free SSL certificates on all applications.

To force redirect from HTTP to HTTPS in Django, set the SECURE_SSL_REDIRECT environment variable to True.

Domain name redirects

You can set up your site's domains using the domains section of the Control Panel. This includes the ability to set a primary and secondary domains. The secondary domains can each be set to redirect to the primary domain if required. You can enable / disable redirects from the three dots menu which will automatically populate DOMAIN, DOMAIN_REDIRECTS and DOMAIN_ALIASES.

Domain redirects/aliases can also be managed manually, via DOMAIN_REDIRECTS / DOMAIN_ALIASES in the env variables section of the Control Panel. The list of domains is comma-separated. Note that doing this overrides all settings applied in the Control Panel - so if you use DOMAIN_REDIRECTS, you will need to list all the domains there yourself. Refer to domain settings and environment variables for more information.

Language redirects

Django provides redirection to the the default language URL when none is specified. (In addition, django CMS offers complex fallback options for unavailable languages.)

For example, /about will redirect to /en/about if English is the default language.

aldryn-django can be configured to not use the prefix for the default language, by checking the Remove URL language prefix for default language checkbox on the settings for the Aldryn Django addon in the Control Panel.

Permanent redirects

ALDRYN_SITES_REDIRECT_PERMANENT will force permanent redirects for protocol and domain directs. This is to be used with caution.