Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect works but rewrite doesn't on an Azure web app

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?

like image 610
Rob Sedgwick Avatar asked Dec 21 '25 15:12

Rob Sedgwick


1 Answers

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

like image 67
Mark van Straten Avatar answered Dec 23 '25 09:12

Mark van Straten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!