Redirects¶

You will find various redirects at work on URLs in Divio Cloud projects.

They fall into different categories:

Protocol redirects¶

Our projects are HTTPS-ready by default, and we provide free SSL certificateseven on free projects.

Adding a SECURE_SSL_REDIRECT will enable these redirects.

Domain name redirects¶

You can set up your site’s domains using the Domains section of the ControlPanel. This includes the ability to set a primary and secondary domains.The secondary domains can each be set to redirect to the primary domain ifrequired.

The domains that are to be redirected to the primary domain can also be managedmanually, via DOMAIN_REDIRECTS.

Language redirects¶

Django provides redirection to the the default language URL when none isspecified. (In addition, django CMS offers complex fallback options forunavailable languages.)

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

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

301 Permanent vs 302 Temporary redirects¶

You will sometimes see online site-checking tools encouraging the use ofpermanent redirects and even flagging temporary redirects as an issue. It istrue that a permanent redirect is sometimes more appropriate, but only when itreally should be permanent, and is guaranteed not to change.

Protocol, domain and language directs are 302 Temporary by default. 301
Permanent
redirects are cached by browsers - some even update their bookmarksif they encounter a 301. This can cause problems if the redirects change,potentially causing redirect loops for users (which site owners will not beable to replicate).

However, we do offer a setting ALDRYN_SITES_REDIRECT_PERMANENT to forcepermanent redirects for protocol and domain directs. This is to be used withcaution.

原文: http://docs.divio.com/en/latest/background/redirects.html