Recursive app_name lookup for separate sub domain application support.

I usually use FQDNs or reverse FQDN we developing web apps. With the current implementation on the second top level below the extension (.dev) is considered.

something.com.dev
and somethingelse.com.dev

would both try to spawn the com app.

This commit recursively looks for a linked app from left to right allowing for the above.

ln -s /var/www/com com
ln -s /var/www/something.com something.com
ln -s /var/www/somethingelse.com somethingelse.com

So com.dev, something.com.dev and somethingelse.com.dev would resolve to their respective apps correctly.

It also still allows for subdomains so notalinkedapp.com.dev would route to the com.dev app, and nothing.something.com.dev would route to the something.com.dev app etc as is kind of the behavour at the moment.

This means no regression for currently configured systems and it would still function the same. 
If you have app.dev configured now, and you are using one.app.dev and two.app.dev both routing to app.dev you will see no change.

Sorry for all the random domain names, I found it hard to illustrate the point.