$search_q = $ENV{'QUERY_STRING'}; $search_q =~ s/\&pg=\d+//; $search_q =~ s/&(?!amp;)/&/g;