Magento: How To use the Secure Base URL for Custom Controllers

This question came up on Magento.SE and more people should know, how dead simple it actually is.

If you look at core/Mage/Checkout/etc/config.xml you can see how Magento defines for the checkout to use the secure base URL, i.e. HTTPS:


That’s all. You can configure your own controllers to use the secure URL in the same way and now Mage::getUrl() returns the secure URL for the configured routes and any unsecure request will be redirected.