WordPress does not have native support for environments where HTTP or HTTPS can be used to access it. The configuration provides only one configurable URL. The presented solution is a more or less simple approach to make WordPress decide which possible URL to use by dynamically altering the siteurl and home value. The secure URL can be completely different from the regular one.
Read more...