Changes

From SME Server
Jump to navigationJump to search
1,014 bytes added ,  01:58, 28 April 2011
db setting code added
Line 94: Line 94:        +
====Modified code to use a db setting====
 +
 +
From http://forums.contribs.org/index.php/topic,47451.msg234224.html#msg234224
 +
 +
This modifies the original code slightly & needs only one 60redir-ibay custom fragment
 +
 +
{
 +
    use esmith::AccountsDB;
 +
    my $adb = esmith::AccountsDB->open_ro();
 +
    $OUT = "";
 +
 +
    foreach my $ibay ($adb->ibays)
 +
    {
 +
      my %properties = $ibay->props;
 +
      my $key = $ibay->key;
 +
      if ($properties{'HTTPSredir'})
 +
      {
 +
          if ($properties{'HTTPSredir'} eq 'on')
 +
          {
 +
            if ($port ne "443")
 +
            {
 +
                $OUT .= "    ## Redirect Web Address to Secure Address\n";
 +
                $OUT .= "    RewriteEngine on\n";
 +
                $OUT .= "    RewriteRule ^/$key(/.*|\$) https://%{HTTP_HOST}/$key\$1 [L,R]\n";
 +
                $OUT .= "    ## End Of Redirect\n";
 +
              }
 +
          }
 +
      }
 +
    }
 +
}
 +
 +
Follow the procedure from the earlier part of this Howto & then issue this db command
 +
 +
db accounts setprop ibayname HTTPSredir on
    
===Alternative method using custom template and db commands===
 
===Alternative method using custom template and db commands===
624

edits

Navigation menu