diff --git a/virtual_feature.pl b/virtual_feature.pl index bb76eab..997069a 100755 --- a/virtual_feature.pl +++ b/virtual_feature.pl @@ -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); } } } @@ -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; @@ -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); } } }