Implement sub-domain redirects while using sitecore URL Rewrite module

For all kind of vanity URL redirection we are using URL Rewrite module in our sitecore project which is running fine. For Ex:

CASE 1

Input URL: www.mysite.com/history

Target URL: www.mysite.com/page1/page2/history --> This is handled by URL Rewrite module

Now we have to handle sub-domain redirection as given below:

CASE 2

Input URL: location.mysite.com

Target URL: www.mysite.com/locations

Input URL: customerfeedback.mysite.com

Target URL: www.mysite.com/company/department/sales/feedback

How should handle these scenario because sub-domain URLs( location.mysite.com ) are pointing to some other servers which are actually serving the pages right now

As a starting point first of all we have to change DNS mapping of given sub-domain URL so that those can start pointing to www.mysite.com Load balancer IP address

What would be the next step. Assuming we might need to write down some custom code for this

UPDATE: See below Input/Target URL configured in Sitecore and redirection using sitecore URL rewrite module feature