Skip to content

Instantly share code, notes, and snippets.

@ashalan
Created July 14, 2015 13:53
Show Gist options
  • Save ashalan/fcd77e35da9cd9833596 to your computer and use it in GitHub Desktop.
Save ashalan/fcd77e35da9cd9833596 to your computer and use it in GitHub Desktop.
diff --git a/domain_path_rewrite.module b/domain_path_rewrite.module
index 6b8d684..d658e5c 100644
--- a/domain_path_rewrite.module
+++ b/domain_path_rewrite.module
@@ -38,8 +38,13 @@ function domain_path_rewrite_url_inbound_alter(&$path, $original_path, $path_lan
*/
function domain_path_rewrite_url_outbound_alter(&$path, &$options, $original_path) {
if ($domain_path = _domain_path_rewrite_domain_path($original_path)) {
- $path = $domain_path['url'];
$options['external'] = strpos($path, '//') !== FALSE;
+ if ($options['external']) {
+ $path = $domain_path['absolute_url'];
+ }
+ else {
+ $path = $domain_path['url'];
+ }
}
}
@@ -68,7 +73,9 @@ function _domain_path_rewrite_domain_path($source) {
$cache[$row->source] = array(
'domain_id' => $row->domain_id,
'path' => $path,
- 'url' => $domains[$row->domain_id]->scheme . '://' . $domains[$row->domain_id]->subdomain . ($path ? '/' . $path : ''),
+ 'domain' => $domains[$row->domain_id]->scheme . '://' . $domains[$row->domain_id]->subdomain,
+ 'absolute_url' => $domains[$row->domain_id]->scheme . '://' . $domains[$row->domain_id]->subdomain . ($path ? '/' . $path : ''),
+ 'url' => ($path ? '/' . $path : ''),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment