isidat
isidat

Reputation: 946

IIS Url Rewrite - Subdomain to folder issue results 404

I want anySubdomain.mydomain.com to behave as mydomain.com/anySubdomain. My configs so far:

  1. I entered a wildcard CNAME record (*.mydomain.com CNAME mydomain.com) in DNS records of mydomain.com. I am pretty sure this step is ok.
  2. I created an inbound rule in URL Rewrite module of web site in IIS as:

    <rewrite>    
    <rules>    
        <rule name="Subdomain to Folder" stopProcessing="true">    
            <match url="(.*)" />    
            <conditions>    
                <add input="{HTTP_HOST}" pattern="[http://]*(.*).mydomain.com" />    
            </conditions>    
            <action type="Rewrite" url="{C:1}/{R:1}" logRewrittenUrl="false" />    
        </rule>    
    </rules>    
    

  3. I created a folder under root folder as anySubdomain and put an index.html into it. I have checked that mydomain.com/anySubdomain gets the page that I want.

I receive a 404 page when I call anySubdomain.mydomain.com. I know this is a common issue but I could not solve this problem, where is my mistake? Thanks.

Upvotes: 0

Views: 1181

Answers (1)

isidat
isidat

Reputation: 946

Finally got the answer, let me share it. The missing step was to add following IIS binding to catch all "has not yet assigned hostnames requests":

IP Address: IP of web server    
Port: 80    
Host: (Leave Blank)    

Upvotes: 1

Related Questions