How to route incoming calls when DID is not available. Only To: field is available

I have two incoming numbers with OVH (

However one is the main number, and the other one is an alias.

When receiving an incoming call from the alias, I always get the DID of the main number, not the alias.

So it is impossible to make any difference so that I can check which incoming number was used, based on DID.

After reading forums, I found a solution that can be ported to Asterisk.

Being uneasy with Asterisk, and using FreePbx, I would like someone to help me port this routine to FreePx.

When debugging the incoming call, there is To: sip:[email protected];user=phone

Where 0033139536703 is indeed the alias number, exactly what I need.

The forum recommends to implement this in Asterisk dial plan :

exten => s,1,Goto(incoming,${CUT(CUT(SIP_HEADER(To),@,1),:, 2)},1)

exten => 0033139536703,1,Dial(SIP/6000,r)

Where 6000 is the extension I want to dial when receiving incoming call from the alias incoming number.

Can someone help me to port this into FreePbx in the easiest way ? I don’t even know where to insert those code lines.
Is there a way to avoid having to edit files in linux, and only have to go through the FreePbx control panel ?