| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
toggle_www_redirect(variable_get('toggle_www_method', 0)); |
if (function_exists('toggle_www_redirect')) { |
| 4 |
|
toggle_www_redirect(variable_get('toggle_www_method', 0)); |
| 5 |
|
} |
| 6 |
|
|
| 7 |
function toggle_www_help($section) { |
function toggle_www_help($section) { |
| 8 |
switch ($section) { |
switch ($section) { |
| 16 |
{ |
{ |
| 17 |
$method = 0; |
$method = 0; |
| 18 |
} |
} |
| 19 |
|
if ($method == 0) { |
| 20 |
|
return; |
| 21 |
|
} |
| 22 |
// $method = 1 means redirect from www.example.com to example.com |
// $method = 1 means redirect from www.example.com to example.com |
| 23 |
if ($method == 1) { |
if ($method == 1) { |
| 24 |
if ( !strstr( $_SERVER['HTTP_HOST'], 'www.' )) // if its already example.com, take no action |
if ( !strstr( $_SERVER['HTTP_HOST'], 'www.' )) // if its already example.com, take no action |
| 26 |
// otherwise pass permanently moved information into header and redirect to example.com |
// otherwise pass permanently moved information into header and redirect to example.com |
| 27 |
header('HTTP/1.1 301 Moved Permanently'); |
header('HTTP/1.1 301 Moved Permanently'); |
| 28 |
header('Location: http://' . substr($_SERVER['HTTP_HOST'], 4) . $_SERVER['REQUEST_URI']); |
header('Location: http://' . substr($_SERVER['HTTP_HOST'], 4) . $_SERVER['REQUEST_URI']); |
| 29 |
exit(); |
return; |
| 30 |
} |
} |
| 31 |
// $method = 2 means redirect from example.com to www.example.com |
// $method = 2 means redirect from example.com to www.example.com |
| 32 |
elseif ($method == 2) { |
elseif ($method == 2) { |
| 35 |
// otherwise pass permanently moved information into header and redirect to www.example.com |
// otherwise pass permanently moved information into header and redirect to www.example.com |
| 36 |
header('HTTP/1.1 301 Moved Permanently'); |
header('HTTP/1.1 301 Moved Permanently'); |
| 37 |
header('Location: http://www.' . substr($_SERVER['HTTP_HOST'], 0) . $_SERVER['REQUEST_URI']); |
header('Location: http://www.' . substr($_SERVER['HTTP_HOST'], 0) . $_SERVER['REQUEST_URI']); |
| 38 |
exit(); |
return; |
| 39 |
} |
} |
| 40 |
} |
} |
| 41 |
|
|