Index: pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 4346)
+++ pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 4347)
@@ -378,5 +378,6 @@
     puts  ("  --no-force-lr       Allow strict-route to be used (i.e. do not force lr)");
     puts  ("  --accept-redirect=N Specify how to handle call redirect (3xx) response.");
-    puts  ("                      0: reject, 1: follow automatically (default), 2: ask");
+    puts  ("                      0: reject, 1: follow automatically,");
+    puts  ("                      2: follow + replace To header (default), 3: ask");
 
     puts  ("");
@@ -405,5 +406,5 @@
     pjsua_transport_config_default(&cfg->rtp_cfg);
     cfg->rtp_cfg.port = 4000;
-    cfg->redir_op = PJSIP_REDIRECT_ACCEPT;
+    cfg->redir_op = PJSIP_REDIRECT_ACCEPT_REPLACE;
     cfg->duration = NO_LIMIT;
     cfg->wav_id = PJSUA_INVALID_ID;
@@ -2242,5 +2243,5 @@
 
     /* accept-redirect */
-    if (config->redir_op != PJSIP_REDIRECT_ACCEPT) {
+    if (config->redir_op != PJSIP_REDIRECT_ACCEPT_REPLACE) {
 	pj_ansi_sprintf(line, "--accept-redirect %d\n",
 			config->redir_op);
@@ -3052,6 +3053,6 @@
 
 	PJ_LOG(3,(THIS_FILE, "Call %d is being redirected to %.*s. "
-		  "Press 'Ra' to accept, 'Rr' to reject, or 'Rd' to "
-		  "disconnect.",
+		  "Press 'Ra' to accept+replace To header, 'RA' to accept, "
+		  "'Rr' to reject, or 'Rd' to disconnect.",
 		  call_id, len, uristr));
     }
@@ -5382,4 +5383,7 @@
 	    } else if (menuin[1] == 'a') {
 		pjsua_call_process_redirect(current_call, 
+					    PJSIP_REDIRECT_ACCEPT_REPLACE);
+	    } else if (menuin[1] == 'A') {
+		pjsua_call_process_redirect(current_call, 
 					    PJSIP_REDIRECT_ACCEPT);
 	    } else if (menuin[1] == 'r') {
Index: pjproject/trunk/pjsip/include/pjsip/sip_util.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsip/sip_util.h	(revision 4346)
+++ pjproject/trunk/pjsip/include/pjsip/sip_util.h	(revision 4347)
@@ -91,4 +91,11 @@
      */
     PJSIP_REDIRECT_ACCEPT,
+
+    /**
+     * Accept the redirection to the current target and replace the To
+     * header in the INVITE request with the current target. The INVITE
+     * request will be resent to the current target.
+     */
+    PJSIP_REDIRECT_ACCEPT_REPLACE,
 
     /**
Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 4346)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 4347)
@@ -1126,7 +1126,6 @@
      * received redirection response.
      *
-     * Application may accept the redirection to the specified target 
-     * (the default behavior if this callback is implemented), reject 
-     * this target only and make the session continue to try the next 
+     * Application may accept the redirection to the specified target,
+     * reject this target only and make the session continue to try the next 
      * target in the list if such target exists, stop the whole
      * redirection process altogether and cause the session to be
@@ -1148,7 +1147,10 @@
      *			parameter to one of the value below:
      *			- PJSIP_REDIRECT_ACCEPT: immediately accept the
-     *			  redirection (default value). When set, the
-     *			  call will immediately resend INVITE request
-     *			  to the target.
+     *			  redirection. When set, the call will immediately
+     *			  resend INVITE request to the target.
+     *			- PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept
+     *			  the redirection and replace the To header with the
+     *			  current target. When set, the call will immediately
+     *			  resend INVITE request to the target.
      *			- PJSIP_REDIRECT_REJECT: immediately reject this
      *			  target. The call will continue retrying with
Index: pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c	(revision 4346)
+++ pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c	(revision 4347)
@@ -2330,4 +2330,5 @@
     switch (op) {
     case PJSIP_REDIRECT_ACCEPT:
+    case PJSIP_REDIRECT_ACCEPT_REPLACE:
     case PJSIP_REDIRECT_STOP:
 	/* Must increment session counter, that's the convention of the 
@@ -2395,4 +2396,5 @@
     switch (op) {
     case PJSIP_REDIRECT_ACCEPT:
+    case PJSIP_REDIRECT_ACCEPT_REPLACE:
 	/* User accept the redirection. Reset the session and resend the 
 	 * INVITE request.
@@ -2419,4 +2421,49 @@
 		  pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
 	    via->branch_param.slen = 0;
+
+	    /* Process PJSIP_REDIRECT_ACCEPT_REPLACE */
+	    if (op == PJSIP_REDIRECT_ACCEPT_REPLACE) {
+		pjsip_to_hdr *to;
+		pjsip_dialog *dlg = inv->dlg;
+		enum { TMP_LEN = 128 };
+		char tmp[TMP_LEN];
+		int len;
+
+		/* Replace To header */
+		to = PJSIP_MSG_TO_HDR(tdata->msg);
+		to->uri = (pjsip_uri*)
+			  pjsip_uri_clone(tdata->pool,
+				          dlg->target_set.current->uri);
+		to->tag.slen = 0;
+		pj_list_init(&to->other_param);
+		
+		/* Re-init dialog remote info */
+		dlg->remote.info = (pjsip_to_hdr*)
+				   pjsip_hdr_clone(dlg->pool, to);
+
+		/* Remove header param from remote info */
+		if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) ||
+		    PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri))
+		{
+		    pjsip_sip_uri *sip_uri = (pjsip_sip_uri *) 
+				   pjsip_uri_get_uri(dlg->remote.info->uri);
+		    if (!pj_list_empty(&sip_uri->header_param)) {
+			/* Remove all header param */
+			pj_list_init(&sip_uri->header_param);
+		    }
+		}
+
+		/* Print the remote info. */
+		len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
+				      dlg->remote.info->uri, tmp, TMP_LEN);
+		if (len < 1) {
+		    pj_ansi_strcpy(tmp, "<-error: uri too long->");
+		    len = pj_ansi_strlen(tmp);
+		}
+		pj_strdup2_with_null(dlg->pool, &dlg->remote.info_str, tmp);
+
+		/* Secure? */
+		dlg->secure = PJSIP_URI_SCHEME_IS_SIPS(to->uri);
+	    }
 
 	    /* Reset message destination info (see #1248). */
