| | |
| | | } |
| | | |
| | | // Set SEO Redirect |
| | | if($data['new']['seo_redirect'] != '' && ($data['new']['subdomain'] == 'www' || $data['new']['subdomain'] == '*')){ |
| | | if($data['new']['seo_redirect'] != ''){ |
| | | $vhost_data['seo_redirect_enabled'] = 1; |
| | | if($data['new']['seo_redirect'] == 'non_www_to_www'){ |
| | | $vhost_data['seo_redirect_origin_domain'] = $data['new']['domain']; |
| | | $vhost_data['seo_redirect_target_domain'] = 'www.'.$data['new']['domain']; |
| | | if($data['new']['subdomain'] == 'www' || $data['new']['subdomain'] == '*'){ |
| | | if($data['new']['seo_redirect'] == 'non_www_to_www'){ |
| | | $vhost_data['seo_redirect_origin_domain'] = $data['new']['domain']; |
| | | $vhost_data['seo_redirect_target_domain'] = 'www.'.$data['new']['domain']; |
| | | $vhost_data['seo_redirect_operator'] = '='; |
| | | } |
| | | if($data['new']['seo_redirect'] == '*_domain_tld_to_www_domain_tld'){ |
| | | // ^(example\.com|(?!\bwww\b)\.example\.com)$ |
| | | // ^(example\.com|((?:\w+(?:-\w+)*\.)*)((?!www\.)\w+(?:-\w+)*)(\.example\.com))$ |
| | | $vhost_data['seo_redirect_origin_domain'] = '^('.str_replace('.', '\.', $data['new']['domain']).'|((?:\w+(?:-\w+)*\.)*)((?!www\.)\w+(?:-\w+)*)(\.'.str_replace('.', '\.', $data['new']['domain']).'))$'; |
| | | $vhost_data['seo_redirect_target_domain'] = 'www.'.$data['new']['domain']; |
| | | $vhost_data['seo_redirect_operator'] = '~*'; |
| | | } |
| | | if($data['new']['seo_redirect'] == '*_to_www_domain_tld'){ |
| | | $vhost_data['seo_redirect_origin_domain'] = 'www.'.$data['new']['domain']; |
| | | $vhost_data['seo_redirect_target_domain'] = $vhost_data['seo_redirect_origin_domain']; |
| | | $vhost_data['seo_redirect_operator'] = '!='; |
| | | } |
| | | } |
| | | if($data['new']['seo_redirect'] == 'www_to_non_www'){ |
| | | $vhost_data['seo_redirect_origin_domain'] = 'www.'.$data['new']['domain']; |
| | | $vhost_data['seo_redirect_target_domain'] = $data['new']['domain']; |
| | | $vhost_data['seo_redirect_operator'] = '='; |
| | | } |
| | | if($data['new']['seo_redirect'] == '*_domain_tld_to_domain_tld'){ |
| | | // ^(.+)\.example\.com$ |
| | | $vhost_data['seo_redirect_origin_domain'] = '^(.+)\.'.str_replace('.', '\.', $data['new']['domain']).'$'; |
| | | $vhost_data['seo_redirect_target_domain'] = $data['new']['domain']; |
| | | $vhost_data['seo_redirect_operator'] = '~*'; |
| | | } |
| | | if($data['new']['seo_redirect'] == '*_to_domain_tld'){ |
| | | $vhost_data['seo_redirect_origin_domain'] = $data['new']['domain']; |
| | | $vhost_data['seo_redirect_target_domain'] = $vhost_data['seo_redirect_origin_domain']; |
| | | $vhost_data['seo_redirect_operator'] = '!='; |
| | | } |
| | | } else { |
| | | $vhost_data['seo_redirect_enabled'] = 0; |
| | |
| | | } else { |
| | | $data['new']['redirect_path'] = 'http'.substr($data['new']['redirect_path'],8); |
| | | } |
| | | } |
| | | |
| | | // Custom proxy directives |
| | | if($data['new']['redirect_type'] == 'proxy' && trim($data['new']['proxy_directives'] != '')){ |
| | | $final_proxy_directives = array(); |
| | | $proxy_directives = $data['new']['proxy_directives']; |
| | | // Make sure we only have Unix linebreaks |
| | | $proxy_directives = str_replace("\r\n", "\n", $proxy_directives); |
| | | $proxy_directives = str_replace("\r", "\n", $proxy_directives); |
| | | $proxy_directive_lines = explode("\n", $proxy_directives); |
| | | if(is_array($proxy_directive_lines) && !empty($proxy_directive_lines)){ |
| | | foreach($proxy_directive_lines as $proxy_directive_line){ |
| | | $final_proxy_directives[] = array('proxy_directive' => $proxy_directive_line); |
| | | } |
| | | } |
| | | } else { |
| | | $final_proxy_directives = false; |
| | | } |
| | | |
| | | switch($data['new']['subdomain']) { |
| | |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude, |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($data['new']['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($data['new']['redirect_type'] == 'proxy' ? true:false)); |
| | | break; |
| | |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude, |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($data['new']['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($data['new']['redirect_type'] == 'proxy' ? true:false)); |
| | | break; |
| | |
| | | 'rewrite_target' => $data['new']['redirect_path'], |
| | | 'rewrite_exclude' => $rewrite_exclude, |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($data['new']['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($data['new']['redirect_type'] == 'proxy' ? true:false)); |
| | | } |
| | |
| | | $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND type != 'vhostsubdomain'"); |
| | | if(is_array($aliases)) { |
| | | foreach($aliases as $alias) { |
| | | |
| | | // Custom proxy directives |
| | | if($alias['redirect_type'] == 'proxy' && trim($alias['proxy_directives'] != '')){ |
| | | $final_proxy_directives = array(); |
| | | $proxy_directives = $alias['proxy_directives']; |
| | | // Make sure we only have Unix linebreaks |
| | | $proxy_directives = str_replace("\r\n", "\n", $proxy_directives); |
| | | $proxy_directives = str_replace("\r", "\n", $proxy_directives); |
| | | $proxy_directive_lines = explode("\n", $proxy_directives); |
| | | if(is_array($proxy_directive_lines) && !empty($proxy_directive_lines)){ |
| | | foreach($proxy_directive_lines as $proxy_directive_line){ |
| | | $final_proxy_directives[] = array('proxy_directive' => $proxy_directive_line); |
| | | } |
| | | } |
| | | } else { |
| | | $final_proxy_directives = false; |
| | | } |
| | | |
| | | if($alias['redirect_type'] == '' || $alias['redirect_path'] == '') { |
| | | switch($alias['subdomain']) { |
| | | case 'www': |
| | |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($alias['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($alias['redirect_type'] == 'proxy' ? true:false)); |
| | | |
| | |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($alias['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($alias['redirect_type'] == 'proxy' ? true:false)); |
| | | break; |
| | |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($alias['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($alias['redirect_type'] == 'proxy' ? true:false)); |
| | | break; |
| | |
| | | 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':$alias['redirect_type'], |
| | | 'rewrite_target' => $alias['redirect_path'], |
| | | 'rewrite_subdir' => $rewrite_subdir, |
| | | 'proxy_directives' => $final_proxy_directives, |
| | | 'use_rewrite' => ($alias['redirect_type'] == 'proxy' ? false:true), |
| | | 'use_proxy' => ($alias['redirect_type'] == 'proxy' ? true:false)); |
| | | } |