| 1 |
<?php |
<?php |
| 2 |
// $Id: globalredirect.module,v 1.1.2.4.2.14 2008/09/05 15:55:22 njt1982 Exp $ |
// $Id: globalredirect.module,v 1.1.2.4.2.15 2008/09/14 23:16:33 njt1982 Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 77 |
} |
} |
| 78 |
|
|
| 79 |
// Trim any trailing slash off the end (eg, 'node/1/' to 'node/1') |
// Trim any trailing slash off the end (eg, 'node/1/' to 'node/1') |
| 80 |
$request = (bool)variable_get('globalredirect_deslash', GLOBALREDIRECT_DESLASH_ENABLED) ? trim($q, '/') : $q; |
$redirect_slash = variable_get('globalredirect_deslash', GLOBALREDIRECT_DESLASH_ENABLED) == GLOBALREDIRECT_DESLASH_ENABLED; |
| 81 |
|
$request = $redirect_slash ? trim($_GET['q'], '/') : $_GET['q']; |
| 82 |
|
|
| 83 |
//Optional stripping of "/0". Defaultly disabled |
// Optional stripping of "/0". Defaultly disabled |
| 84 |
switch (variable_get('globalredirect_trailingzero', GLOBALREDIRECT_FEATURE_DISABLED)) { |
switch (variable_get('globalredirect_trailingzero', GLOBALREDIRECT_FEATURE_DISABLED)) { |
| 85 |
case GLOBALREDIRECT_TRAILINGZERO_TAXTERM : |
case GLOBALREDIRECT_TRAILINGZERO_TAXTERM : |
| 86 |
// If 'taxonomy/term/*' only. If not, break out. |
// If 'taxonomy/term/*' only. If not, break out. |
| 100 |
$alias = drupal_get_path_alias($request); |
$alias = drupal_get_path_alias($request); |
| 101 |
|
|
| 102 |
// If alias is different to the request, redirect... |
// If alias is different to the request, redirect... |
| 103 |
if ($alias != $_REQUEST['q']) { |
if ($alias != $request) { |
| 104 |
drupal_goto($alias, $query_string, NULL, 301); |
drupal_goto($alias, $query_string, NULL, 301); |
| 105 |
} |
} |
| 106 |
|
|
| 107 |
// If the trimmed request differs to the request then redirect (basically, de-slash the source path). |
// If the trimmed request differs to the request then redirect (basically, de-slash the source path). |
| 108 |
if ($request != $q) { |
if ($redirect_slash && ($request != $q)) { |
| 109 |
drupal_goto($request, $query_string, NULL, 301); |
drupal_goto($request, $query_string, NULL, 301); |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
// If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled. |
// If no alias was returned, the final check is to direct non-clean to clean - if clean is enabled. |
| 113 |
if ((bool)variable_get('globalredirect_nonclean2clean', GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED) && (bool)variable_get('clean_url', 0) && strpos(request_uri(), '?q=')) { |
if (variable_get('globalredirect_nonclean2clean', GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED) == GLOBALREDIRECT_NONCLEAN2CLEAN_ENABLED && (bool)variable_get('clean_url', 0) && strpos(request_uri(), '?q=')) { |
| 114 |
drupal_goto($request, $query_string, NULL, 301); |
drupal_goto($request, $query_string, NULL, 301); |
| 115 |
} |
} |
| 116 |
|
|