Option to change redirects to use just a path

This commit is contained in:
Jamie Cameron
2013-03-10 18:11:55 -07:00
parent c97f51916f
commit 4e1a32c78e
5 changed files with 32 additions and 3 deletions

View File

@@ -1232,14 +1232,29 @@ if ($_[0] =~ /^(http|https|ftp|gopher):/) {
}
elsif ($_[0] =~ /^\//) {
# Absolute path (like /foo/bar.cgi)
$url = "$prot://$ENV{'SERVER_NAME'}$port$wp$_[0]";
if ($gconfig{'relative_redir'}) {
$url = "$wp$_[0]";
}
else {
$url = "$prot://$ENV{'SERVER_NAME'}$port$wp$_[0]";
}
}
elsif ($ENV{'SCRIPT_NAME'} =~ /^(.*)\/[^\/]*$/) {
# Relative URL (like foo.cgi)
$url = "$prot://$ENV{'SERVER_NAME'}$port$wp$1/$_[0]";
if ($gconfig{'relative_redir'}) {
$url = "$wp$1/$_[0]";
}
else {
$url = "$prot://$ENV{'SERVER_NAME'}$port$wp$1/$_[0]";
}
}
else {
$url = "$prot://$ENV{'SERVER_NAME'}$port/$wp$_[0]";
if ($gconfig{'relative_redir'}) {
$url = "$wp$_[0]";
}
else {
$url = "$prot://$ENV{'SERVER_NAME'}$port/$wp$_[0]";
}
}
&load_theme_library();
if (defined(&theme_redirect)) {

View File

@@ -116,3 +116,5 @@ The titles for existing clone modules can now be changed on the Module Titles pa
---- Changes since 1.610 ----
Added a page for viewing and running Webmin scheduled functions.
Added a section to the Sending Email page to verify that the configured mail server settings work.
---- Changes since 1.620 ----
Added a setting to the Web Server Options page to control if redirects use just a path, or the full URL.

View File

@@ -44,6 +44,9 @@ if ($in{'gzip'} == 1) {
}
$miniserv{'gzip'} = $in{'gzip'};
# Save redirect type
$gconfig{'relative_redir'} = $in{'redir'};
# Save global config
&lock_file("$config_directory/config");
&write_file("$config_directory/config", \%gconfig);

View File

@@ -54,6 +54,12 @@ print &ui_table_row($text{'advanced_gzip'},
[ 0, $text{'advanced_gzip0'} ],
[ 1, $text{'advanced_gzip1'} ] ]));
# Redirect type
print &ui_table_row($text{'advanced_redir'},
&ui_radio("redir", $gconfig{'relative_redir'} ? 1 : 0,
[ [ 1, $text{'advanced_redir1'} ],
[ 0, $text{'advanced_redir0'} ] ]));
print &ui_table_end();
print &ui_form_end([ [ "save", $text{'save'} ] ]);

View File

@@ -830,6 +830,9 @@ advanced_gzipauto=Only if pre-compressed .gz file exists
advanced_gzip0=Never
advanced_gzip1=Use pre-compressed file and compress dynamically
advanced_egzip=Gzip compression cannot be enabled unless the $1 perl module is installed
advanced_redir=URL format for redirects
advanced_redir1=Path only
advanced_redir0=Protocol, host, port and path
syslog_errorlog=Webmin error log