anchor.diff:      %% Here Code is 3xx
       ?Debug("in redir ~p", [Code]),
       H = get(outh),
  -    DecPath = safe_decode_path(Req#http_request.path),
  -    Loc = if
  -              Mode == append ->
  -                  NPath   = filename:join([URL#url.path ++ DecPath]),
  -                  LocPath = yaws_api:format_partial_url(URL#url{path=NPath},
  -                                                        get(sc)),
  -                  ["Location: ", LocPath, "\r\n"];
  -              true -> %% noappend
  -                  LocPath = yaws_api:format_partial_url(URL, get(sc)),
  -                  case yaws:split_at(DecPath, $?) of
  -                      {_, []} -> ["Location: ", LocPath, "\r\n"];
  -                      {_, Q}  -> ["Location: ", LocPath, "?", Q, "\r\n"]
  -                  end
  -          end,
  +    QueryData = case Arg#arg.querydata of
  +                    undefined -> [];
  +                    Q         -> Q
  +                end,
  +    LocPath = if
  +                  Mode == append ->
  +                      EncPath = yaws_api:url_encode(Arg#arg.server_path),
  +                      Path1   = filename:join([URL#url.path ++ EncPath]),
  +                      yaws_api:format_partial_url(
  +                        URL#url{path=Path1,querypart=QueryData}, get(sc)
  +                       );
  +                  true -> %% noappend
  +                      yaws_api:format_partial_url(URL#url{querypart=QueryData},
  +                                                  get(sc))
  +              end,
  +    Loc = ["Location: ", LocPath, "\r\n"],
  +
       {DoClose, _Chunked} = yaws:dcc(Req, Arg#arg.headers),
       new_redir_h(H#outh{
                     connection = yaws:make_connection_close_header(DoClose),
  
positive.code:                      {_Prefix, Code, Path, Mode}, N) when is_list(Path) ->
      %% Here Code is 1xx, 2xx, 4xx or 5xx
      ?Debug("in redir ~p", [Code]),
      DecPath = safe_decode_path(Req#http_request.path),
      Page = if
                 Mode == append ->
                     filename:join([Path ++ DecPath]);
                 true -> %% noappend
                     case yaws:split_at(DecPath, $?) of
                         {_, []} -> Path;
                         {_, Q}  -> Path ++ "?" ++ Q
                     end
             end,
  
      %% Set variables used in handle_method_result/7
  
negative.code: 
                      case {IsRev, IsRedirect} of
                          {_, {true, Redir}} ->
                              ARG1 = ARG#arg{server_path = DecPath,
                                             querydata   = QueryString},
                              deliver_redirect_map(CliSock, Req, ARG1, Redir, N);
                          {false, _} ->
                              %%'main' branch so to speak. Most requests
                              %% pass through here.
  