Commit 046d621d authored by mcramer's avatar mcramer
Browse files

Fixed: redirect loop on redirect path

parent 056b11eb
......@@ -257,7 +257,10 @@
</tmpl_if>
<tmpl_loop name="redirects">
RewriteCond %{HTTP_HOST} <tmpl_var name='rewrite_domain'>$ [NC]
RewriteCond %{REQUEST_URI} !^/webdav/
<tmpl_if name="rewrite_is_url" op="==" value="n">
RewriteCond %{REQUEST_URI} !^/webdav/
RewriteCond %{REQUEST_URI} !^<tmpl_var name='rewrite_target'>
</tmpl_if>
RewriteRule ^/(.*)$ <tmpl_var name='rewrite_target'>$1 <tmpl_var name='rewrite_type'>
</tmpl_loop>
</tmpl_if>
......
......@@ -887,23 +887,27 @@ class apache2_plugin {
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($data['new']['domain']),
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
$rewrite_rules[] = array( 'rewrite_domain' => '^' . $this->_rewrite_quote('www.'.$data['new']['domain']),
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
break;
case '*':
$rewrite_rules[] = array( 'rewrite_domain' => '(^|\.)'.$this->_rewrite_quote($data['new']['domain']),
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
break;
default:
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($data['new']['domain']),
'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
}
}
......@@ -968,17 +972,20 @@ class apache2_plugin {
$rewrite_rules[] = array( 'rewrite_domain' => '^'.$this->_rewrite_quote($alias['domain']),
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
$rewrite_rules[] = array( 'rewrite_domain' => '^' . $this->_rewrite_quote('www.'.$alias['domain']),
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
break;
case '*':
$rewrite_rules[] = array( 'rewrite_domain' => '(^|\.)'.$this->_rewrite_quote($alias['domain']),
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
break;
default:
if(substr($alias['domain'], 0, 2) === '*.') $domain_rule = '(^|\.)'.$this->_rewrite_quote(substr($alias['domain'], 2));
......@@ -986,7 +993,8 @@ class apache2_plugin {
$rewrite_rules[] = array( 'rewrite_domain' => $domain_rule,
'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']',
'rewrite_target' => $rewrite_target,
'rewrite_target_ssl' => $rewrite_target_ssl);
'rewrite_target_ssl' => $rewrite_target_ssl,
'rewrite_is_url' => ($this->_is_url($rewrite_target) ? 'y' : 'n'));
}
}
}
......@@ -2567,6 +2575,10 @@ class apache2_plugin {
return str_replace(array('.', '*', '?', '+'), array('\\.', '\\*', '\\?', '\\+'), $string);
}
private function _is_url($string) {
return preg_match('/^(f|ht)tp(s)?:\/\//i', $string);
}
} // end class
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment