anchor.diff:                       {_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
  +    Path1 = if
  +                Mode == append ->
  +                    EncPath = yaws_api:url_encode(Arg#arg.server_path),
  +                    filename:join([Path ++ EncPath]);
  +                true -> %% noappend
  +                    Path
  +            end,
  +    Page = case Arg#arg.querydata of
  +               undefined -> Path1;
  +               []        -> Path1;
  +               Q         -> Path1 ++ "?" ++ Q
              end,
   
       %% Set variables used in handle_method_result/7
  
positive.code: 
                      case {IsRev, IsRedirect} of
                          {_, {true, Redir}} ->
                              deliver_redirect_map(CliSock, Req, ARG, Redir, N);
                          {false, _} ->
                              %%'main' branch so to speak. Most requests
                              %% pass through here.
  
negative.code: %% we must deliver a 302 if the browser asks for a dir
  %% without a trailing / in the HTTP req
  %% otherwise the relative urls in /dir/index.html will be broken.
  %% Note: Here Path is always decoded, so we must encode it
  deliver_302(CliSock, _Req, Arg, Path) ->
      ?Debug("in redir 302 ",[]),
      H = get(outh),
      SC=get(sc),
      Scheme  = yaws:redirect_scheme(SC),
      Headers = Arg#arg.headers,
      EncPath = yaws_api:url_encode(Path),
      RedirHost = yaws:redirect_host(SC, Headers#headers.host),
  
      %% QueryString must be added
      Loc = case Arg#arg.querydata of
                undefined -> ["Location: ", Scheme, RedirHost, EncPath, "\r\n"];
                [] -> ["Location: ", Scheme, RedirHost, EncPath, "\r\n"];
                Q -> ["Location: ", Scheme, RedirHost, EncPath, "?", Q, "\r\n"]
            end,
      new_redir_h(H, Loc),
      deliver_accumulated(CliSock),
  