corrected usage of default redirect code from settings; fixes #546
Signed-off-by: Michael Kaufmann <michael.kaufmann@aixit.com>
This commit is contained in:
@@ -36,9 +36,11 @@ function getRedirectCodesArray() {
|
||||
* return an array of all enabled redirect-codes
|
||||
* for the settings form
|
||||
*
|
||||
* @param bool $add_desc optional, default true, add the code-description
|
||||
*
|
||||
* @return array array of enabled redirect-codes
|
||||
*/
|
||||
function getRedirectCodes() {
|
||||
function getRedirectCodes($add_desc = true) {
|
||||
|
||||
global $lng;
|
||||
|
||||
@@ -47,7 +49,10 @@ function getRedirectCodes() {
|
||||
|
||||
$codes = array();
|
||||
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$codes[$rc['id']] = $rc['code']. ' ('.$lng['redirect_desc'][$rc['desc']].')';
|
||||
$codes[$rc['id']] = $rc['code'];
|
||||
if ($add_desc) {
|
||||
$codes[$rc['id']] .= ' ('.$lng['redirect_desc'][$rc['desc']].')';
|
||||
}
|
||||
}
|
||||
|
||||
return $codes;
|
||||
@@ -58,12 +63,17 @@ function getRedirectCodes() {
|
||||
* domain-id
|
||||
*
|
||||
* @param integer $domainid id of the domain
|
||||
* @param string $default
|
||||
*
|
||||
* @return string redirect-code
|
||||
*/
|
||||
function getDomainRedirectCode($domainid = 0, $default = '') {
|
||||
function getDomainRedirectCode($domainid = 0) {
|
||||
|
||||
// get system default
|
||||
$default = '301';
|
||||
if (Settings::Get('customredirect.enabled') == '1') {
|
||||
$all_codes = getRedirectCodes(false);
|
||||
$default = $all_codes[Settings::Get('customredirect.default')];
|
||||
}
|
||||
$code = $default;
|
||||
if ($domainid > 0) {
|
||||
|
||||
|
||||
@@ -964,7 +964,7 @@ class apache extends HttpConfigBase
|
||||
$corrected_docroot = $domain['documentroot'];
|
||||
|
||||
// Get domain's redirect code
|
||||
$code = getDomainRedirectCode($domain['id'], '301');
|
||||
$code = getDomainRedirectCode($domain['id']);
|
||||
$modrew_red = '';
|
||||
if ($code != '') {
|
||||
$modrew_red = ' [R=' . $code . ';L,NE]';
|
||||
|
||||
@@ -467,7 +467,7 @@ class lighttpd extends HttpConfigBase
|
||||
$uri = $domain['documentroot'];
|
||||
|
||||
// Get domain's redirect code
|
||||
$code = getDomainRedirectCode($domain['id'], '301');
|
||||
$code = getDomainRedirectCode($domain['id']);
|
||||
|
||||
$vhost_content .= ' url.redirect-code = ' . $code. "\n";
|
||||
$vhost_content .= ' url.redirect = (' . "\n";
|
||||
|
||||
@@ -486,7 +486,7 @@ class nginx extends HttpConfigBase
|
||||
}
|
||||
|
||||
// Get domain's redirect code
|
||||
$code = getDomainRedirectCode($domain['id'], '301');
|
||||
$code = getDomainRedirectCode($domain['id']);
|
||||
|
||||
$vhost_content .= "\t" . 'if ($request_uri !~ ^/.well-known/acme-challenge/\w+$) {' . "\n";
|
||||
$vhost_content .= "\t\t" . 'return ' . $code .' ' . $uri . '$request_uri;' . "\n";
|
||||
|
||||
Reference in New Issue
Block a user