diff --git securepages.module securepages.module index c2ef84b..67111b1 100644 --- securepages.module +++ securepages.module @@ -138,6 +138,30 @@ function securepages_link_alter(&$links, $node) { } /** + * Implementation of hook_url_outbound_alter() + * + * Rewrite links to the correct domain immediately when the url_alter module is available + */ +function securepages_url_outbound_alter(&$path, &$options, $original_path) { + if ($path == '') { + $path = variable_get('site_frontpage', 'node'); + } + if (variable_get('securepages_enable', 1)) { + if ($path && !$options['external'] && securepages_can_alter_url($path)) { + $page_match = securepages_match($path); + if ($page_match && !securepages_is_secure()) { + $options['absolute'] = TRUE; + $options['base_url'] = securepages_baseurl(TRUE); + } + elseif ($page_match === 0 && securepages_is_secure() && variable_get('securepages_switch', FALSE)) { + $options['absolute'] = TRUE; + $options['base_url'] = securepages_baseurl(FALSE); + } + } + } +} + +/** * Check the current page and see if we need to redirect to the secure or * insecure version of the page. */