Redirecting subdomain to directory on Azure

1k views Asked by At

Simply put, how can I redirect test.example.com to example.com? I would like to make the sub-domain seem "real" to the user(redirection in the background, URL is still test.example.com/index.html). I have tried modifying my DNS settings on the domain, the IIS configuration, and added my sub-domain to my Azure configuration.

Web.Config

<rule name="Push Subdomain to Push folder">
<match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^test.example.com$" />
    </conditions>
<action type="Rewrite" url="http://example.com/test/{R:1}" />

My DNS Configuration:

Sub-Domain: test | URL: example.azurewebsites.net | Record Type: CNAME (alias)

When I do this, I get this error message: The page cannot be displayed because an internal server error has occurred.

1

There are 1 answers

1
melotic On BEST ANSWER

I have fixed the issue by changing the above to

<rule name="Rewrite sub-domain to dir" enabled="true">
<match url="^(.*)$" />
<conditions>
    <add input="{HTTP_HOST}" pattern="^test\.example\.com$" />
</conditions>
<action type="Rewrite" url="test/{R:1}" />