Azure web site - URL Rewrite using web.config not

2019-06-23 07:12发布

问题:

We are migrating some sites over to Azure and I have it setup as a "Web Site".

An example of what we're trying to do is pretty straight forward.

Current URL: http://www.website.com/Products.aspx Clean URL: http://www.website.com/Products/

So in the web.config, there is the following:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="ProductList">
                <match url="/Products.aspx" />
                <action type="Redirect" url="/Products" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

This was generated in IIS. I have tried to set the stopProcess attribute to true... which is a solution that I've seen in a few threads, but nothing is working.

This website is one of our legacy sites that uses an ISAPI module for Rewrites. Since we aren't using an Azure VM, we cannot continue using this method to rewrite.

Is there something I'm missing here?

回答1:

Azure Web Sites does not have the URL Rewrite module installed, so the config approach won't work. Maybe you could update the site code to use ASP.NET URL routing, as described in this blog post by Scott Gu: http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx

Azure Web Sites didn't used to have the URL Rewrite Module installed, but now it does, so you can just use the standard <system.webServer><rewrite> section in your web.config.