From af486448586d3a97f3951d876671626381c0c6c3 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Thu, 13 Oct 2011 08:29:39 -0400
Subject: [PATCH] - Fixed #1798.

---
 server/conf/vhost.conf.master                   |   48 +++++++++++-------------
 server/plugins-available/apache2_plugin.inc.php |   32 ++++++++++++---
 2 files changed, 47 insertions(+), 33 deletions(-)

diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master
index 410d44d..ae1287d 100644
--- a/server/conf/vhost.conf.master
+++ b/server/conf/vhost.conf.master
@@ -174,23 +174,23 @@
 	# For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
     <IfModule mod_fcgid.c>
 <tmpl_if name='fastcgi_config_syntax' op='==' value='2'>
-	  FcgidIdleTimeout 300
-	  FcgidProcessLifeTime 3600
-	  FcgidMaxProcesses 1000
-	  FcgidMinProcessesPerClass 0
-	  FcgidMaxProcessesPerClass 100
-	  FcgidConnectTimeout 3
-	  FcgidIOTimeout 360
-	  FcgidBusyTimeout 300
+        FcgidIdleTimeout 300
+        FcgidProcessLifeTime 3600
+        FcgidMaxProcesses 1000
+        FcgidMinProcessesPerClass 0
+        FcgidMaxProcessesPerClass 100
+        FcgidConnectTimeout 3
+        FcgidIOTimeout 360
+        FcgidBusyTimeout 300
 <tmpl_else>
-	  IdleTimeout 300
-	  ProcessLifeTime 3600
-	  # MaxProcessCount 1000
-	  DefaultMinClassProcessCount 0
-	  DefaultMaxClassProcessCount 100
-	  IPCConnectTimeout 3
-	  IPCCommTimeout 360
-	  BusyTimeout 300
+        IdleTimeout 300
+        ProcessLifeTime 3600
+        # MaxProcessCount 1000
+        DefaultMinClassProcessCount 0
+        DefaultMaxClassProcessCount 100
+        IPCConnectTimeout 3
+        IPCCommTimeout 360
+        BusyTimeout 300
 </tmpl_if>
     </IfModule>
     <Directory {tmpl_var name='web_document_root_www'}>
@@ -201,7 +201,7 @@
         Order allow,deny
         Allow from all
     </Directory>
-	<Directory {tmpl_var name='web_document_root'}>
+    <Directory {tmpl_var name='web_document_root'}>
         AddHandler fcgid-script .php .php3 .php4 .php5
         FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
         Options +ExecCGI
@@ -210,17 +210,13 @@
         Allow from all
     </Directory>
 </tmpl_if>
-<tmpl_if name="rewrite_enabled">
-    
-    RewriteEngine on
-	
-<tmpl_if name='seo_redirect_enabled'>
 
+<tmpl_if name="rewrite_enabled">
+    RewriteEngine on
+<tmpl_if name='seo_redirect_enabled'>
     RewriteCond %{HTTP_HOST} ^<tmpl_var name='seo_redirect_origin_domain'>$ [NC]
     RewriteRule ^(.*)$ http://<tmpl_var name='seo_redirect_target_domain'>/$1 [R=301,L]
-
 </tmpl_if>
-
 <tmpl_loop name="redirects">
     RewriteCond %{HTTP_HOST}   <tmpl_var name='rewrite_domain'>$ [NC]
     RewriteRule   ^/(.*)$ <tmpl_var name='rewrite_target'>$1  <tmpl_var name='rewrite_type'>
@@ -234,11 +230,11 @@
 
     <IfModule mod_dav_fs.c>
 	  # Do not execute PHP files in webdav directory
-	  <Directory {tmpl_var name='document_root'}/webdav>
+      <Directory {tmpl_var name='document_root'}/webdav>
 	    <FilesMatch "\.ph(p3?|tml)$">
           SetHandler None
         </FilesMatch>
-	  </Directory>
+      </Directory>
       # DO NOT REMOVE THE COMMENTS!
       # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
       # WEBDAV BEGIN
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 65f5cf5..f0e9203 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -827,12 +827,13 @@
 			$tpl->setVar('alias','');
 		}
 
-		if(count($rewrite_rules) > 0) {
+		if(count($rewrite_rules) > 0 || $vhost_data['seo_redirect_enabled'] > 0) {
 			$tpl->setVar('rewrite_enabled',1);
 		} else {
 			$tpl->setVar('rewrite_enabled',0);
 		}
-		$tpl->setLoop('redirects',$rewrite_rules);
+
+		//$tpl->setLoop('redirects',$rewrite_rules);
 
 		/**
 		 * install fast-cgi starter script and add script aliasd config
@@ -957,22 +958,39 @@
 		//* create empty vhost array
 		$vhosts = array();
 		
-		//* Add vhost for ipv4 IP
-		$vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 0, 'port' => 80 );
+		//* Add vhost for ipv4 IP	
+		if(count($rewrite_rules) > 0){
+			$vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 0, 'port' => 80, 'redirects' => $rewrite_rules);
+		} else {
+			$vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 0, 'port' => 80);
+		}
 		
 		//* Add vhost for ipv4 IP with SSL
 		if($data['new']['ssl_domain'] != '' && $data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file) && (@filesize($crt_file)>0)  && (@filesize($key_file)>0)) {
-			$vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 1, 'port' => '443' );
+			if(count($rewrite_rules) > 0){
+				$vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 1, 'port' => '443', 'redirects' => $rewrite_rules);
+			} else {
+				$vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 1, 'port' => '443');
+			}
 			$app->log('Enable SSL for: '.$domain,LOGLEVEL_DEBUG);
 		}
 		
 		//* Add vhost for IPv6 IP
 		if($data['new']['ipv6_address'] != '') {
-			$vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 0, 'port' => 80 );
+			if(count($rewrite_rules) > 0){
+				$vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 0, 'port' => 80, 'redirects' => $rewrite_rules);
+			} else {
+				$vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 0, 'port' => 80);
+			}
 		
 			//* Add vhost for ipv6 IP with SSL
 			if($data['new']['ssl_domain'] != '' && $data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file) && (@filesize($crt_file)>0)  && (@filesize($key_file)>0)) {
-				$vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 1, 'port' => '443' );
+				
+				if(count($rewrite_rules) > 0){
+					$vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 1, 'port' => '443', 'redirects' => $rewrite_rules);
+				} else {
+					$vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 1, 'port' => '443');
+				}
 				$app->log('Enable SSL for IPv6: '.$domain,LOGLEVEL_DEBUG);
 			}
 		}

--
Gitblit v1.9.1