[WIP] Fixes #2477 - Implemented optional subdomains using regex

@DASPRID
@fatmuemoo
@ralphschindler

This fixes #2477 by matching the hostname using regex. Existing tests have not been changed and all pass so this should have no BC break.