Fixes #2477 - Implemented optional subdomains using regex

@DASPRID instead of #3825, this is a PR to master instead of develop as requested by @weierophinney