What if you have more than one number ending up at the same VoIP account, but you want to route each number to a different phone? If you are lucky, your sip provider still has the originally dialed number in the To: field of the SIP message. Then a snippet like the following might help you:
exten => _X.,1,Set(CALLEDNUM=${SIP_HEADER(To)})
exten => _X.,n,Set(CALLEDNUM=${CALLEDNUM:5})
exten => _X.,n,Set(CALLEDNUM=${CUT(CALLEDNUM,@,1)})
exten => _X.,n,NoOp(${CALLEDNUM})
exten => _X.,n,Goto(${CALLEDNUM},1)You need to have the module app_cut.so loaded for this to work.