<span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(51, 51, 51)"><div><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(51, 51, 51)">Thank you for the answer, Klaus</span></div>
<div><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(51, 51, 51)"><br></span></div><div><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(51, 51, 51)">I have tried your way(commented my subst and added your rows), so now it looks like this:</span></div>
<div><span style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse;color:rgb(51, 51, 51)"><div><br></div><div>failure_route[2] {</div><div><span style="white-space:pre">        </span>if (!t_is_canceled() && t_check_status("486|408")) { </div>
<div><span style="white-space:pre">                </span>$avp(alias_seq)=$avp(alias_seq)+1;</div><div><span style="white-space:pre">                </span>xdbg("HERE WE ARE! $avp(alias_seq)\n"); </div>
<div><span style="white-space:pre">                </span>revert_uri();</div><div><span style="white-space:pre">                </span>sql_query("main", "select username from subscriber where alias='$tU' and alias_seq='$avp(alias_seq)'", "alias_name"); </div>
<div><span style="white-space:pre">                </span>sql_query("main", "select domain from subscriber where alias='$tU' and alias_seq='$avp(alias_seq)'", "alias_domain"); </div>
<div><span style="white-space:pre">                </span>if ($dbr(alias_name=>rows) != 0 && $dbr(alias_domain=>rows) != 0) {</div><div><span style="white-space:pre">                        </span>subst_uri('/^sip:.*@.*$/sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])/');</div>
<div># subst('/^To:.*<sip:.*>/To: <sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])>\r\n/'); <--COMMENTED OUT THIS ONE</div><div><span style="white-space:pre">                        </span>remove_hf("To"); # <--ADDED THIS ONE </div>
<div><span style="white-space:pre">                        </span>append_hf("To: <sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])>\r\n"); # <--ADDED THIS ONE</div><div><span style="white-space:pre">                        </span>sql_result_free("alias_name");</div>
<div><span style="white-space:pre">                        </span>sql_result_free("alias_domain");</div><div><span style="white-space:pre">                        </span>setflag(10);</div><div><span style="white-space:pre">                        </span>if (!lookup("location")) {</div>
<div><span style="white-space:pre">                        </span> switch ($retcode) {</div><div><span style="white-space:pre">                                </span>case -1:</div><div><span style="white-space:pre">                                </span>case -3:</div>
<div><span style="white-space:pre">                                        </span>t_reply("404", "Not Found");</div><div><span style="white-space:pre">                                        </span>exit;</div><div><span style="white-space:pre">                                </span>case -2:</div>
<div><span style="white-space:pre">                                        </span>exit;</div><div><span style="white-space:pre">                        </span> }</div><div><span style="white-space:pre">                        </span>}</div>
<div><span style="white-space:pre">                        </span>append_branch();</div><div><span style="white-space:pre">                        </span>route(5);</div><div><span style="white-space:pre">                </span>}</div>
<div><span style="white-space:pre">        </span>}</div><div><span style="white-space:pre">        </span>if (is_method("INVITE")) {</div><div><span style="white-space:pre">                </span>unforce_rtp_proxy();</div>
<div><span style="white-space:pre">        </span>}<span style="white-space:pre">                </span></div><div><br></div><div>}</div><div><br></div><div>route[5] {</div><div><span style="white-space:pre">        </span>if (!t_relay()) {</div>
<div><span style="white-space:pre">                </span>sl_reply_error();</div><div><span style="white-space:pre">        </span>}</div><div><span style="white-space:pre">        </span>exit;</div>
<div>}</div></span></div><div><br></div><div>So the code now supposed to delete "To: <<a href="mailto:sip%3Ancm0000b@domain.com">sip:ncm0000b@domain.com</a>>"</div><div>and to append "To: <<a href="mailto:sip%3Ancm0000a@domain.com">sip:ncm0000a@domain.com</a>>"</div>
<div><div style="font-size: small; "><br></div><div style="font-size: small; ">But with ngrep i can see:</div><div style="font-size: small; ">To: <<a href="mailto:sip%3Ancm0000b@domain.com">sip:ncm0000b@domain.com</a>>.Date: Tue, 08 Jun 2010 09:40:10 GMT.</div>
<div style="font-size: small; "><br></div></div><div style="font-size: small; ">With timestamp, which seems to me to be unusual.</div><div style="font-size: small; "><br></div></span><div><font class="Apple-style-span" color="#333333" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">So maybe it's impossible to rewrite "To" header from failure_route for some reason... (For example according to RFC)</span></font></div>
<div><font class="Apple-style-span" color="#333333" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" color="#333333" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Actually my phones ring, and everything works fine, I am just interested with this behavior of Kamailio.</span></font></div>
<div><font class="Apple-style-span" color="#333333" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" color="#333333" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">Thanks again for your reply. </span></font></div>
<div><font class="Apple-style-span" color="#333333" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div>Sincerely yours,<br>Kosilov Fedor.<br>
<br><br><div class="gmail_quote">2010/6/8 Klaus Darilion <span dir="ltr"><<a href="mailto:klaus.mailinglists@pernau.at" target="_blank">klaus.mailinglists@pernau.at</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div> remove_hf("To");<br>
append_hf("To: <sip:$dbr(alias_name=>[0,0])@$dbr(alias_domain=>[0,0])>\r\n");</div></blockquote></div><br>
</div>