Magetno 2 base url 302 redirection

Hi I am trying to implement add extra key to base url example my base url:: abcd.com if user click on any key with base_url like below user entered url :: pawan.abcd.com site need set new theme if pawan key found my custom table. If not fount i need to redirect to home page or base url means site will work regular format if key found only new theme will assign can you please tell how can achieve this.

Present my site abcd.com if i click pawan.abcd.com it redirecting to abcd.com i am not redirecting but it redirecting automatically i have installed wild card ssl like *.abcd.com

can any one tell how to stop that automatic redirection