/[drupal]/contributions/modules/toggle_www/toggle_www.module
ViewVC logotype

Diff of /contributions/modules/toggle_www/toggle_www.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Sat Oct 21 11:27:35 2006 UTC revision 1.3, Sat Oct 21 11:47:04 2006 UTC
# Line 1  Line 1 
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) {
# Line 14  if ($_SERVER['HTTP_HOST'] == 'localhost' Line 16  if ($_SERVER['HTTP_HOST'] == 'localhost'
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
# Line 21  if ($method == 1) { Line 26  if ($method == 1) {
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) {
# Line 30  elseif ($method == 2) { Line 35  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    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2