From 09cfec7747cb4e44841e688b4b3f90442f8431f8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 2 Jan 2016 23:13:18 +0000 Subject: www: redirect with query string We use query strings for search and index pages, so we should not drop them if somebody types a URL by hand and omits the trailing slash. --- lib/PublicInbox/WWW.pm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/PublicInbox/WWW.pm') diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index ee414e85..b4c050b1 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -358,15 +358,19 @@ sub r301 { my ($ctx, $listname, $mid, $suffix) = @_; my $cgi = $ctx->{cgi}; my $url; + my $qs; if (ref($cgi) eq 'CGI') { $url = $cgi->url(-base) . '/'; + $qs = $cgi->query_string; } else { $url = $cgi->base->as_string; + $qs = $cgi->env->{QUERY_STRING}; } $url .= $listname . '/'; $url .= (uri_escape_utf8($mid) . '/') if (defined $mid); $url .= $suffix if (defined $suffix); + $url .= "?$qs" if $qs ne ''; [ 301, [ Location => $url, 'Content-Type' => 'text/plain' ], -- cgit v1.2.3-24-ge0c7