Index: globalredirect.module =================================================================== --- globalredirect.module (revision 1607) +++ globalredirect.module (working copy) @@ -124,30 +124,33 @@ function globalredirect_init() { $path = isset($_REQUEST['q']) ? $_REQUEST['q'] : ''; language_url_rewrite($path, $options); } - $prefix = rtrim($options['prefix'], '/'); + $prefix = $options['prefix']; + if (function_exists('custom_url_rewrite_outbound')) { + custom_url_rewrite_outbound($prefix, $options, $path); + } + // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1') + $redirect_slash = variable_get('globalredirect_deslash', GLOBALREDIRECT_DESLASH_ENABLED) == GLOBALREDIRECT_DESLASH_ENABLED; + $request = $redirect_slash ? trim($_GET['q'], '/') : $_GET['q']; + $prefix = $redirect_slash ? trim($prefix, '/') : $prefix; // Do a check if this is a front page if (drupal_is_front_page()) { // Redirect if the current request does not refer to the front page in the // configured fashion (with or without a prefix) if (isset($_REQUEST['q']) && $_REQUEST['q'] != $prefix) { - drupal_goto('', $query_string, NULL, 301); + drupal_goto($prefix, $query_string, NULL, 301); } elseif ((variable_get('globalredirect_nonclean2clean', GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED) == GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED) && ((bool)variable_get('clean_url', 0)) && (strpos(request_uri(), '?q=') || strpos(request_uri(), 'index.php'))) { - drupal_goto('', $query_string, NULL, 301); + drupal_goto($prefix, $query_string, NULL, 301); } // If we've got to this point then we're on a front page with a VALID // request path (such as a language-prefix front page such as '/de') return; } - // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1') - $redirect_slash = variable_get('globalredirect_deslash', GLOBALREDIRECT_DESLASH_ENABLED) == GLOBALREDIRECT_DESLASH_ENABLED; - $request = $redirect_slash ? trim($_GET['q'], '/') : $_GET['q']; - // Optional stripping of "/0". Disabled by default. switch (variable_get('globalredirect_trailingzero', GLOBALREDIRECT_FEATURE_DISABLED)) { case GLOBALREDIRECT_TRAILINGZERO_TAXTERM : @@ -167,13 +170,6 @@ function globalredirect_init() { // Find an alias (if any) for the request $langcode = isset($options['language']->language) ? $options['language']->language : ''; $alias = drupal_get_path_alias($request, $langcode); - if (function_exists('custom_url_rewrite_outbound')) { - // Modules may alter outbound links by reference. - custom_url_rewrite_outbound($alias, $options, $request); - } - if ($prefix && $alias) { - $prefix .= '/'; - } // Alias case sensitivity check. If there is an alias from the previous // lookup, do a query to test for case. @@ -185,11 +181,15 @@ function globalredirect_init() { } } + if (function_exists('custom_url_rewrite_outbound')) { + // Modules may alter outbound links by reference. + custom_url_rewrite_outbound($alias, $options, $request); + } // Compare the request to the alias. This also works as a 'deslashing' // agent. If we have a language prefix then prefix the alias - if ($_REQUEST['q'] != $prefix . $alias) { + if ($_REQUEST['q'] != $alias) { // If it's not just a slash or user has deslash on, redirect - if (str_replace($prefix . $alias, '', $_REQUEST['q']) != '/' || $redirect_slash) { + if (str_replace($alias, '', $_REQUEST['q']) != '/' || $redirect_slash) { drupal_goto($alias, $query_string, NULL, 301); } } @@ -226,4 +226,4 @@ function globalredirect_menu() { */ function globalredirect_is_cli() { return (!isset($_SERVER['SERVER_SOFTWARE']) && (PHP_SAPI == 'cli' || (is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0))); -} +} \ No newline at end of file