{
   $OUT = "        # AWV Rewrite\n";
   $OUT .= "       RewriteEngine on\n";

   use esmith::ConfigDB;
   my $db = esmith::ConfigDB->open("/home/e-smith/db/awcconf") or die "Couldn't open AWV ConfigDB\n";

   #       Add the following text if HTTPS_ONLY is 'Y'
   #        #let requests from local pass through
   #        RewriteCond %{REMOTE_HOST}  ^localhost  [OR]
   #        RewriteCond %{REMOTE_HOST}  ^127.0.0.1
   #        Rewriterule ^/.* - [L]
   #
   #        #requests for / when in HTTPS_ONLY mode
   #        RewriteCond %{SERVER_PORT}      !^443$
   #        Rewriterule ^/$                 https://%{SERVER_NAME}/ [L,R=301]
   #
   #        #requests for everything else in HTTPS_ONLY mode
   #        RewriteCond %{SERVER_PORT}      !^443$
   #        Rewriterule ^/(.*)              https://%{SERVER_NAME}/$1 [L,R=301]
   #

   my $haveSSL = (exists ${modSSL}{status} and ${modSSL}{status} eq "enabled") ?  'yes' : 'no';
   my $https_redirect = "";
   my $https = $db->get_value(HTTPS_ONLY);
   my $security = "";
   if ($https eq "Y" )
   {
      $https_redirect=<<END_HTTPS;
         #let requests from local pass through
         RewriteCond %{REMOTE_HOST}  ^localhost  [OR]
         RewriteCond %{REMOTE_HOST}  ^127.0.0.1
         Rewriterule ^/awc/.* - [L]

         #requests for / when in HTTPS_ONLY mode
         RewriteCond %{SERVER_PORT}      !^443\$
         Rewriterule ^/awc/\$                 https://%{SERVER_NAME}/awc/ [L,R=301]

         #requests for everything else in HTTPS_ONLY mode
         RewriteCond %{SERVER_PORT}      !^443\$
         Rewriterule ^/awc/(.*)              https://%{SERVER_NAME}/awc/\$1 [L,R=301]
END_HTTPS
   }

   if (($port eq "80") && ($haveSSL eq 'yes'))
   {
      $security = "      RewriteRule ^/awcuser/cgi-bin/vcs(.*) https://%{SERVER_NAME}/awcuser/cgi-bin/vcs\$1 [R,L]\n";
   }
   #       RewriteRule ^/wcrs\$/(.*) /wd/$1 [PT]
   #       RewriteRule ^/call/(.*) /cgi-bin/conference?access_code=$1 [PT]

   my $connpoint_redirect=<<END_CONNPOINT;
      RewriteRule ^/wcrs\\\$/InteractiveDemo/(.*) /wd/\$1 [PT]
      RewriteRule ^/wcrs\\\$/(.*) /wd/\$1 [PT]
      RewriteRule ^/call/(.*) /awcuser/cgi-bin/conference?access_code=\$1 [R]
END_CONNPOINT

my $webclientframe=<<END_WEBCLIENT_FRAME;
   <IfModule mod_headers.c>
        # Unset X-Frame-Options for some urls
     <LocationMatch "^/wd/.*(hc_main.html|hc_main_util.asp)">
          Header always unset X-Frame-Options
        </LocationMatch>
      </IfModule>
END_WEBCLIENT_FRAME


my $userRedirects=<<END_USER_REDIRECTS;
#   RewriteLog  "/var/log/httpd/rewrite.log"
#   RewriteLogLevel 3
    RewriteRule ^/awc/\$  /awcuser/cgi-bin/vcs?xml=withXsl&xsl=/vcs/vcs_home.xsl&publicawv=true&show_codes=&current_vanities=&settings=global;user;phone&show_port_res_settings [R]
END_USER_REDIRECTS

   $OUT .= $https_redirect.$security.$connpoint_redirect.$userRedirects.$webclientframe;
   $OUT .= "       # End of AWV Rewrite\n";
}
