Index: globalredirect.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/globalredirect/globalredirect.module,v retrieving revision 1.1.2.4.2.7 diff -u -p -r1.1.2.4.2.7 globalredirect.module --- globalredirect.module 29 Dec 2007 15:19:53 -0000 1.1.2.4.2.7 +++ globalredirect.module 16 Apr 2008 19:23:44 -0000 @@ -18,24 +18,39 @@ function globalredirect_help($section) { function globalredirect_init() { if(isset($_REQUEST['q']) && function_exists('drupal_get_path_alias') && !isset($_REQUEST['destination'])) { + // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1') + $request = trim($_REQUEST['q'], '/'); + + // Remove a language prefix in the path if existent (multilingual support). + if (!empty($request) && function_exists('i18n_get_lang')) { + $languages = locale_supported_languages(); + $languages = $languages['name']; + $args = explode('/', $request); + $prefix = array_shift($args); + // Search prefix within enabled languages. + if (isset($languages[$prefix])) { + $request = implode('/', $args); + } + } + + // Early-out (the front page is requested). + if (empty($request)) { + return; + } + // Get the Query String (minus the 'q'). If none set, set to NULL $query_string = drupal_query_string_encode($_GET, array('q')); if (empty($query_string)) { $query_string = NULL; } - // If current path is also the frontpage, redirect to http://www.example.com. - if (!empty($_REQUEST['q']) && drupal_is_front_page()) { + // If current path is also the front page, redirect to the front page. + if (drupal_is_front_page()) { drupal_goto('', $query_string, NULL, 301); } - // Trim any trailing slash off the end (eg, 'node/1/' to 'node/1') - $request = trim($_REQUEST['q'], '/'); - - // Check the path (eg, node/123) for an request. + // Redirect to the URL alias of this path if existent. $alias = drupal_get_path_alias($request); - - // If alias is different to the request, redirect... if ($alias != $request) { drupal_goto($alias, $query_string, NULL, 301); }