sub import {
hook(type => "cgi", id => '404', call => \&cgi);
+ hook(type => "getsetup", id => '404', call => \&getsetup);
IkiWiki::loadplugin("goto");
}
# server admin action too
safe => 0,
rebuild => 0,
+ section => "web",
}
}
sub cgi ($) {
my $cgi=shift;
- if ($ENV{REDIRECT_STATUS} eq '404') {
- my $page = cgi_page_from_404($ENV{REDIRECT_URL},
+ if (exists $ENV{REDIRECT_STATUS} &&
+ $ENV{REDIRECT_STATUS} eq '404') {
+ my $page = cgi_page_from_404(
+ Encode::decode_utf8($ENV{REDIRECT_URL}),
$config{url}, $config{usedirs});
IkiWiki::Plugin::goto::cgi_goto($cgi, $page);
}