3
votes

I am trying to redirect from my old ISP to my azure web site. I have set up the necessary DNS records. As I am using sub-folders on my Web App I need to set up redirection rules in the root web.config file to point from the domain name to the correct sub-folder of the main site.

It works perfectly when I have a redirect rule.

            <rule name="Works" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^mysite.com$" />
                </conditions>
                <action type="Redirect" url="http://mysite.azurewebsites.net/mysub"/>
            </rule>              

However when I change to a Rewrite it fails. I really want a rewrite as I don't want the user to see the change of url in the browser.

            <rule name="Fails" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^mysite.com$" />
                </conditions>
                <action type="Rewrite" url="http://mysite.azurewebsites.net/mysub"/>
            </rule>              

I get the following message:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

What am I doing wrong?

1

1 Answers

1
votes

Your rewrite action should be a relative path, see the documentation:

http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#Rewrite_action

A substitution string must always specify the URL path