Skip to content

Commit

Permalink
Add working redirect from /awstats
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Sep 23, 2023
1 parent d4d1bda commit 89d00b8
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions virtual_feature.pl
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,29 @@ sub feature_setup
$d->{'dom'}, $port);
if ($virt) {
my $conf = &apache::get_config();
my $done;
my @sa = &apache::find_directive(
"ScriptAlias", $vconf);
my ($aw) = grep { $_ =~ /^\/awstats/ } @sa;
if (!$aw) {
# Need to add
push(@sa, "/awstats/ $cgidir/");
push(@sa, "/awstats $cgidir/awstats.pl");
&apache::save_directive("ScriptAlias", \@sa,
$vconf, $conf);
$done++;
}
my @rm = &apache::find_directive(
"RedirectMatch", $vconf);
my ($rm) = grep { $_ =~ /^\^\/awstats\$\s+\/awstats/ } @rm;
if (!$rm) {
&apache::save_directive("RedirectMatch",
['^/awstats$ /awstats/'], $vconf, $conf);
$done++;
}
if ($done) {
&flush_file_lines($virt->{'file'});
&virtual_server::register_post_action(
\&virtual_server::restart_apache);
\&virtual_server::restart_apache);
}
}
}
Expand Down Expand Up @@ -463,6 +475,7 @@ sub feature_delete
$d->{'dom'}, $port);
if ($virt) {
my $conf = &apache::get_config();
my $done;
my @sa = &apache::find_directive(
"ScriptAlias", $vconf);
my ($aw) = grep { $_ =~ /^\/awstats/ } @sa;
Expand All @@ -471,9 +484,22 @@ sub feature_delete
@sa = grep { $_ ne $aw } @sa;
&apache::save_directive("ScriptAlias", \@sa,
$vconf, $conf);
$done++;
}
my @rm = &apache::find_directive(
"RedirectMatch", $vconf);
my ($rm) = grep { $_ =~ /^\^\/awstats\$\s+\/awstats\// } @rm;
if ($rm) {
@rm = grep { $_ ne $rm } @rm;
&apache::save_directive(
"RedirectMatch", \@rm,
$vconf, $conf);
$done++;
}
if ($done) {
&flush_file_lines($virt->{'file'});
&virtual_server::register_post_action(
\&virtual_server::restart_apache);
\&virtual_server::restart_apache);
}
}
}
Expand Down

0 comments on commit 89d00b8

Please sign in to comment.