Creating multi subdomain host on iis like *.domain.com

barak golan 1 Reputation point
2021-11-10T20:43:15.587+00:00

Hello,
I'm working on a aspnet core application that accept user requests as subdomains such as => user1.mywebsite.com, user2.mywebsite.com etc etc

Is there a way on iis to accept every subdomain without adding it to the site binding, or do I have to add every user as sub domain to the iis site binding?

Basically I wanna create *.mywebsite.com host (see attached pic)
148235-capture.png

Is there any way to create something like this?
I'm using windows server 2012 r2
Thanks in advance

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,767 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. MotoX80 35,231 Reputation points
    2021-11-11T01:16:43.973+00:00

    As you may already know, that functionality was added to IIS 10. Looks like 2012R2 is IIS 8.5.

    https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/wildcard-host-header-support

    Assuming that you already have multiple web sites on that server, one way to accomplish a wildcard (sort of), would be to add a second IP to the server. In the bindings for that site, add in the second IP address. But leave the host name field blank. IIS will accept any name.

    1 person found this answer helpful.

  2. Sam Wu-MSFT 7,536 Reputation points Microsoft Vendor
    2021-11-11T02:27:54.887+00:00

    @barak golan

    I'm working on a aspnet core application that accept user requests as subdomains such as => user1.mywebsite.com, user2.mywebsite.com etc etc

    What is your purpose for multiple subdomains? I think you can change your mind, you can use url redirect to redirect the subdomain to the url you want, so you don’t need to add it to the site bindings. for how to redirect from sub domain to main domain or other url, you can refer to this rule:

    <rule name="Test Rule" stopProcessing="true">  
         <match url=".*" />  
              <conditions>  
                   <add input="{HTTP_HOST}" pattern="^((.+.)?)mywebsite.com" />  
              </conditions>  
         <action type="Redirect" url="https://newdomain.com/{R:0}" appendQueryString="false" />  
    </rule>  
    

    If I misunderstand your requirement, please post more details information about your requirement.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Limitless Technology 39,781 Reputation points
    2021-11-12T09:27:17.883+00:00

    Hi there,

    Each website has to have a unique combination of IP address + TCP port + Host Header. A valid value for Host header is "blank", however, since the combination must be unique amongst all websites, only a single website on a specific IP address + TCP port can have a blank host header.

    If you have a blank host header value, then any request which doesn't match a more specific IP address + TCP Port + Host header binding will be routed to the site with the blank host header value in the binding.

    You can get more info from here , Multiple Domains and subdomains for one website
    https://social.msdn.microsoft.com/Forums/en-US/9263f4dc-e509-4dcd-a4bb-cb87c823fd1c/multiple-domains-and-subdomains-for-one-website?forum=iis7general


    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    2 deleted comments

    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.