Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure web site - URL Rewrite using web.config not working

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?

like image 404
Director of Technology Avatar asked Dec 05 '13 21:12

Director of Technology


People also ask

How do I enable rewrite module on azure website?

Url Rewrite module is enabled by default on Azure websites and you can create your rewrite or redirect rules using a web.config. Open the Web.config file located at the site root (D:\home\site\wwwroot). If you do not have a Web.config file in the directory, create it.

How to create rewrite or redirect rules on azure websites?

Url Rewrite module is enabled by default on Azure websites and you can create your rewrite or redirect rules using a web.config. Open the Web.config file located at the site root (D:\home\site\wwwroot). If you do not have a Web.config file in the directory, create it. Copy and paste the following XML section into the system.webServer element:

How do I redirect a URL to another URL in azure?

The solution is to use an URL rewrite solution, which will redirect the simple URL to the composed URL. We can achieve this using an Azure Web app. The following are the steps which will be conducted during this walk-through: Create an Azure Web app. Configure the Azure Web app. Create the URL Rewrite Configuration file.

Does mod_rewrite work with azure websites?

Azure Websites use the IIS web server and hence does not work with mod_rewrite which is an Apache module. Url Rewrite module is enabled by default on Azure websites and you can create your rewrite or redirect rules using a web.config. Open the Web.config file located at the site root (D:\home\site\wwwroot).


1 Answers

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.

like image 95
Mark Rendle Avatar answered Oct 26 '22 18:10

Mark Rendle