You can can try configuring your routes to have a custom constraint to match on the host header (in the example below the route would only match if the host header equals myheader.com):
_config.Routes.MapHttpRoute(
"API Default", "{controller}/{id}",
new { id = RouteParameter.Optional },
new { headerMatch = new HostHeaderConstraint("myheader.com")});
The constraint code would be something like:
public class HostHeaderConstraint : IRouteConstraint
{
private readonly string _header;
public HostHeaderContraint(string header)
{
_header = header;
}
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
var hostHeader = httpContext.Request.ServerVariables["HTTP_HOST"];
return hostHeader.Equals(_header, StringComparison.CurrentCultureIgnoreCase);
}
}