diff -u -r -N ispconfig-3.0.5.branch/interface/lib/classes/tform.inc.php ispconfig-3.0.5.branch.patched/interface/lib/classes/tform.inc.php
--- ispconfig-3.0.5.branch/interface/lib/classes/tform.inc.php	2013-08-04 11:00:17.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/lib/classes/tform.inc.php	2013-08-09 22:14:23.000000000 +0200
@@ -888,39 +888,74 @@
 										  }
                                         }
                                 break;
-				/*
-				case 'ISV6PREFIX':
-					$v6_prefix_ok = 0;
-					$explode_field_value = explode(':',$field_value);
-					if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){
-					        if ( count($explode_field_value) <= 9 ) {
-					                if(filter_var(substr($field_value,0,strlen($field_value)-2),FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).'::0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).':0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) ) {
-					                        $v6_prefix_ok = 1;
-                					}
-        					}
-					} else { 
-						$v6_prefix_ok = 2; 
-					}
-					// check subnet against defined server-ipv6
-					$sql_v6 = $app->db->queryOneRecord("SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND virtualhost = 'y' LIMIT 0,1");
-					$sql_v6_explode=explode(':',$sql_v6['ip_address']);
-					if ( count($sql_v6_explode) < count($explode_field_value) && isset($sql_v6['ip_address']) )  { 
-						$v6_prefix_ok = 3; 
-					}
-					if($v6_prefix_ok == 0) { 
-						$errmsg = $validator['errmsg']; 
-					}
-					if($v6_prefix_ok == 2) { 
-						$errmsg = 'IPv6 Prefix must end with ::'; 
-					}
-					if($v6_prefix_ok == 3) { 
-						$errmsg = 'IPv6 Prefix too long (according to Server IP Addresses)'; 
-					}
-					if($v6_prefix_ok <> 1){
-						$this->errorMessage .= $errmsg."<br />\r\n"; 
-					}
-				break;
-				*/
+                                // check IPv6 against defined prefix - server ip addresses
+                                case 'IPV6MATCHPREFIX':
+                                        $app->uses('getconf');
+                                        $_server = $app->getconf->get_server_config(1,'server');
+                                        // check only if the ip is a IPv6-address
+                                        if ( (filter_var($field_value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) && isset($_server["v6_prefix"]) ) {
+                                                // return errmsg if the prefix doesn't  match the IPv6
+                                                if (strncmp($field_value,$_server['v6_prefix'],strlen($_server['v6_prefix'])-1) <> 0 ) {
+//                                                      echo error;
+                                                        $errmsg = $validator['errmsg'];
+                                                        if(isset($this->wordbook[$errmsg])) {
+                                                                $this->errorMessage .= $this->wordbook[$errmsg].$_server["v6_prefix"]."<br />\r\n";
+                                                        } else {
+                                                                $this->errorMessage .= $errmsg."<br />\r\n";
+                                                        }
+                                                }
+
+                                        }
+                                break;
+                                // IPv6-prefix must end with :: - server configuration
+                                case 'V6PREFIXEND':
+                                        $explode_field_value = explode(':',$field_value);
+                                        if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){ }
+                                        else {
+                                                $errmsg = $validator['errmsg'];
+                                                if(isset($this->wordbook[$errmsg])) {
+                                                        $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
+                                                } else {
+                                                        $this->errorMessage .= $errmsg."<br />\r\n";
+                                                }
+                                        }
+                                break;
+                                // IPv6 prefix can't be longer than the shortest IPv6 - server configuration
+                                case 'V6PREFIXLENGTH':
+                                        // find the shortest ipv6 because the prefix can`t be longer
+                                        $sql_v6 = $app->db->queryOneRecord("SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND virtualhost = 'y' ORDER BY CHAR_LENGTH(ip_address) ASC LIMIT 0,1;");
+                                        $sql_v6_explode=explode(':',$sql_v6['ip_address']);
+                                        $explode_field_value = explode(':',$field_value);
+                                        if ( count($sql_v6_explode) < count($explode_field_value) && isset($sql_v6['ip_address']) ) {
+                                                $errmsg = $validator['errmsg'];
+                                                if(isset($this->wordbook[$errmsg])) {
+                                                        $this->errorMessage .= $this->wordbook[$errmsg].$sql_v6[ip_address]."<br />\r\n";
+                                                } else {
+                                                        $this->errorMessage .= $errmsg."<br />\r\n";
+                                                }
+                                        }
+                                break;
+                                // the prefix must be a valid IPv6 prefix - server configuration
+                                case 'ISV6PREFIX':
+                                        $v6_prefix_ok = 0;
+                                        $explode_field_value = explode(':',$field_value);
+                                        if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){
+                                                if ( count($explode_field_value) <= 9 ) {
+                                                        if (filter_var(substr($field_value,0,strlen($field_value)-2),FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).'::0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).':0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) ) {
+                                                                $v6_prefix_ok = 1;
+                                                        }
+                                                }
+                                        }
+                                                if($v6_prefix_ok <> 1){
+                                                        $errmsg = $validator['errmsg'];
+                                                        if(isset($this->wordbook[$errmsg])) {
+                                                                $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
+                                                        } else {
+                                                              $this->errorMessage .= $errmsg."<br />\r\n";
+                                                        }
+                                                }
+                                break;
+
 								case 'ISIPV4':
 								$vip=1;
 								if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
diff -u -r -N ispconfig-3.0.5.branch/interface/web/admin/form/server_config.tform.php ispconfig-3.0.5.branch.patched/interface/web/admin/form/server_config.tform.php
--- ispconfig-3.0.5.branch/interface/web/admin/form/server_config.tform.php	2013-07-30 17:19:41.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/web/admin/form/server_config.tform.php	2013-08-09 14:20:28.000000000 +0200
@@ -86,16 +86,18 @@
 			'width' => '15',
 			'maxlength' => '255'
 		),
-		/*
-		'v6_prefix' => array(
-			'datatype' => 'VARCHAR',
-			'formtype' => 'TEXT',
-                        'validators' => array(0 => array('type' => 'ISV6PREFIX',
-                                        'errmsg' => 'v6_prefix_wrong'),
-                        ),
-		'default' => ''
-		),
-		*/
+                'v6_prefix' => array(
+                        'datatype' => 'VARCHAR',
+                        'formtype' => 'TEXT',
+                        'validators' => array(  0 => array('type' => 'ISV6PREFIX',
+                                                'errmsg' => 'v6_prefix_wrong'),
+                                                1 => array('type' => 'V6PREFIXEND',
+                                                'errmsg' => 'v6_prefix_end'),
+                                                2 => array('type' => 'V6PREFIXLENGTH',
+                                                'errmsg' => 'v6_prefix_length')
+                        ),
+                        'default' => ''
+                ),
 		'gateway' => array(
 			'datatype' => 'VARCHAR',
 			'formtype' => 'TEXT',
@@ -509,14 +511,12 @@
 			'width' => '40',
 			'maxlength' => '255'
 		),
-/*
-'vhost_rewrite_v6' => array (
-'datatype' => 'VARCHAR',
-'formtype' => 'CHECKBOX',
-'default' => 'n',
-'value' => array(0 => 'n',1 => 'y')
-),
-*/
+                'vhost_rewrite_v6' => array (
+                        'datatype' => 'VARCHAR',
+                        'formtype' => 'CHECKBOX',
+                        'default' => 'n',
+                        'value' => array(0 => 'n',1 => 'y')
+                ),
 		'vhost_conf_dir' => array(
 			'datatype' => 'VARCHAR',
 			'formtype' => 'TEXT',
diff -u -r -N ispconfig-3.0.5.branch/interface/web/admin/form/server_ip.tform.php ispconfig-3.0.5.branch.patched/interface/web/admin/form/server_ip.tform.php
--- ispconfig-3.0.5.branch/interface/web/admin/form/server_ip.tform.php	2013-07-30 17:19:41.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/web/admin/form/server_ip.tform.php	2013-08-09 14:22:29.000000000 +0200
@@ -125,6 +125,7 @@
 														'errmsg'=> 'ip_error_wrong'),
 										1 => array (	'type'	=> 'UNIQUE',
 														'errmsg'=> 'ip_error_unique'),
+										2 => array ( 'type' => 'IPV6MATCHPREFIX', 'errmsg'=> 'ip_error_v6prefix'),
 									),
 			'default'	=> '',
 			'value'		=> '',
@@ -161,4 +162,4 @@
 	##################################
 	)
 );
-?>
\ No newline at end of file
+?>
diff -u -r -N ispconfig-3.0.5.branch/interface/web/admin/lib/lang/en_server_config.lng ispconfig-3.0.5.branch.patched/interface/web/admin/lib/lang/en_server_config.lng
--- ispconfig-3.0.5.branch/interface/web/admin/lib/lang/en_server_config.lng	2013-07-30 17:19:41.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/web/admin/lib/lang/en_server_config.lng	2013-08-09 14:23:19.000000000 +0200
@@ -170,6 +170,12 @@
 $wb["web_folder_protection_txt"] = 'Make web folders immutable (extended attributes)';
 $wb["overtraffic_notify_admin_txt"] = 'Send overtraffic notification to admin';
 $wb["overtraffic_notify_client_txt"] = 'Send overtraffic notification to client';
+$wb["v6_prefix_txt"] = 'IPv6 Prefix';
+$wb["v6_prefix_note_txt"] = 'only for rewrite on mirrors';
+$wb["vhost_rewrite_v6_txt"] = 'Rewrite IPv6 on Mirror';
+$wb["v6_prefix_wrong"] = 'Invalid v6 Netmask format.';
+$wb["v6_prefix_end"] = 'Prefix - must end with ::';
+$wb["v6_prefix_length"] = 'Prefix too long according to defined IPv6 ';
 $wb["rbl_error_regex"] = 'Please specify valid RBL hostnames.';
 $wb["overquota_notify_admin_txt"] = 'Send quota warnings to admin';
 $wb["overquota_notify_client_txt"] = 'Send quota warnings to client';
@@ -188,4 +194,5 @@
 $wb['munin_password_txt'] = 'Munin Password';
 $wb['munin_url_error_regex'] = 'Invalid Munin URL';
 $wb['munin_url_note_txt'] = 'Placeholder:';
+
 ?>
diff -u -r -N ispconfig-3.0.5.branch/interface/web/admin/lib/lang/en_server_ip.lng ispconfig-3.0.5.branch.patched/interface/web/admin/lib/lang/en_server_ip.lng
--- ispconfig-3.0.5.branch/interface/web/admin/lib/lang/en_server_ip.lng	2013-05-30 17:04:40.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/web/admin/lib/lang/en_server_ip.lng	2013-08-09 14:23:45.000000000 +0200
@@ -7,5 +7,6 @@
 $wb["virtualhost_port_txt"] = 'HTTP Ports';
 $wb["ip_error_wrong"] = 'The IP address is invalid';
 $wb["ip_error_unique"] = 'The IP address must be unique';
+$wb["ip_error_v6prefix"] = 'The IP address must match the IPv6-prefix ';
 $wb["error_port_syntax"] = 'Invalid chars in port field, please enter only comma separated numbers. Example: 80,443';
-?>
\ No newline at end of file
+?>
diff -u -r -N ispconfig-3.0.5.branch/interface/web/admin/templates/server_config_server_edit.htm ispconfig-3.0.5.branch.patched/interface/web/admin/templates/server_config_server_edit.htm
--- ispconfig-3.0.5.branch/interface/web/admin/templates/server_config_server_edit.htm	2013-07-30 17:19:41.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/web/admin/templates/server_config_server_edit.htm	2013-08-09 14:27:09.000000000 +0200
@@ -19,11 +19,10 @@
                 <label for="netmask">{tmpl_var name='netmask_txt'}</label>
                 <input name="netmask" id="netmask" value="{tmpl_var name='netmask'}" size="15" maxlength="255" type="text" class="textInput formLengthIPv4" />
             </div>
-	   <!--<div class="ctrlHolder">
+	   <div class="ctrlHolder">
 		<label for="v6_prefix">{tmpl_var name='v6_prefix_txt'}</label>
-		<input name="v6_prefix" id="v6_prefix" value="{tmpl_var name='v6_prefix'}" size="15" maxlength="255" type="text" class="textInput formLengthIPv4" />
+		<input name="v6_prefix" id="v6_prefix" value="{tmpl_var name='v6_prefix'}" size="15" maxlength="255" type="text" class="textInput formLengthIPv4" />&nbsp;{tmpl_var name='v6_prefix_note_txt'}
            </div>
-		   -->
             <div class="ctrlHolder">
                 <label for="gateway">{tmpl_var name='gateway_txt'}</label>
                 <input name="gateway" id="gateway" value="{tmpl_var name='gateway'}" size="15" maxlength="255" type="text" class="textInput formLengthIPv4" />
diff -u -r -N ispconfig-3.0.5.branch/interface/web/admin/templates/server_config_web_edit.htm ispconfig-3.0.5.branch.patched/interface/web/admin/templates/server_config_web_edit.htm
--- ispconfig-3.0.5.branch/interface/web/admin/templates/server_config_web_edit.htm	2013-07-15 17:47:56.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/interface/web/admin/templates/server_config_web_edit.htm	2013-08-09 14:28:08.000000000 +0200
@@ -35,14 +35,12 @@
                 <label for="website_autoalias">{tmpl_var name='website_autoalias_txt'}</label>
                 <input name="website_autoalias" id="website_autoalias" value="{tmpl_var name='website_autoalias'}" size="40" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='website_autoalias_note_txt'} <a href="javascript:void(0);" class="addPlaceholder">[client_id]</a>, <a href="javascript:void(0);" class="addPlaceholder">[client_username]</a>, <a href="javascript:void(0);" class="addPlaceholder">[website_id]</a>, <a href="javascript:void(0);" class="addPlaceholder">[website_domain]</a>
             </div>
-			<!--
 		<div class="ctrlHolder apache">
 			<label for="vhost_rewrite_v6">{tmpl_var name='vhost_rewrite_v6_txt'}</label>
 			<div class="multiField">
 				{tmpl_var name='vhost_rewrite_v6'}
 			</div>
 		</div>
-			-->
             <div class="ctrlHolder apache">
                 <label for="vhost_conf_dir">{tmpl_var name='vhost_conf_dir_txt'}</label>
                 <input name="vhost_conf_dir" id="vhost_conf_dir" value="{tmpl_var name='vhost_conf_dir'}" size="40" maxlength="255" type="text" class="textInput" />
diff -u -r -N ispconfig-3.0.5.branch/server/plugins-available/apache2_plugin.inc.php ispconfig-3.0.5.branch.patched/server/plugins-available/apache2_plugin.inc.php
--- ispconfig-3.0.5.branch/server/plugins-available/apache2_plugin.inc.php	2013-08-09 11:39:27.000000000 +0200
+++ ispconfig-3.0.5.branch.patched/server/plugins-available/apache2_plugin.inc.php	2013-08-09 14:30:43.000000000 +0200
@@ -1315,6 +1315,9 @@
 		$vhosts = array();
 		
 		//* Add vhost for ipv4 IP
+                if (isset($conf['ipv4_replace']) && $conf['ipv4_replace'] <> "" && $data['new']['ip_address'] <> '*') {
+                        $data['new']['ip_address'] = $conf['ipv4_replace'];
+                }
 		$tmp_vhost_arr = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 0, 'port' => 80);
 		if(count($rewrite_rules) > 0)  $tmp_vhost_arr = $tmp_vhost_arr + array('redirects' => $rewrite_rules);
 		if(count($alias_seo_redirects) > 0) $tmp_vhost_arr = $tmp_vhost_arr + array('alias_seo_redirects' => $alias_seo_redirects);
@@ -1344,17 +1347,20 @@
 		
 	//* Add vhost for IPv6 IP
 	if($data['new']['ipv6_address'] != '') {
-		if ($conf['serverconfig']['web']['vhost_rewrite_v6'] == 'y') {
-			if (isset($conf['serverconfig']['server']['v6_prefix']) && $conf['serverconfig']['server']['v6_prefix'] <> '') {
-				$explode_v6prefix=explode(':',$conf['serverconfig']['server']['v6_prefix']);
-				$explode_v6=explode(':',$data['new']['ipv6_address']);
-
-				for ( $i = 0; $i <= count($explode_v6prefix)-3; $i++ ) {
-				        $explode_v6[$i] = $explode_v6prefix[$i];
-				}
-				$data['new']['ipv6_address'] = implode(':',$explode_v6);
-			}
-		}
+                if ($web_config["vhost_rewrite_v6"] == 'y' && $conf['serverconfig']['server']['v6_prefix'] <> '') {
+                        if (isset($conf['serverconfig']['server']['v6_prefix']) && $conf['serverconfig']['server']['v6_prefix'] <> '') {
+                                $explode_v6prefix=explode(':',$conf['serverconfig']['server']['v6_prefix']);
+                                 $explode_v6=explode(':',$data['new']['ipv6_address']);
+                                 for ( $i = 0; $i <= count($explode_v6prefix)-3; $i++ ) {
+                                        $explode_v6[$i] = $explode_v6prefix[$i];
+                                 }
+                                 $data['new']['ipv6_address'] = implode(':',$explode_v6);
+                         }
+                }
+
+                        $tmp_vhost_arr = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 0, 'port' => 80);
+                        if(count($rewrite_rules) > 0)  $tmp_vhost_arr = $tmp_vhost_arr + array('redirects' => $rewrite_rules);
+
 			
 			$tmp_vhost_arr = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 0, 'port' => 80);
 			if(count($rewrite_rules) > 0)  $tmp_vhost_arr = $tmp_vhost_arr + array('redirects' => $rewrite_rules);
