简体   繁体   English

Azure网站 - 使用web.config重写URL无法正常工作

[英]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". 我们正在将一些站点迁移到Azure,并将其设置为“Web站点”。

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/ 当前网址: http//www.website.com/Products.aspx清洁网址: http//www.website.com/Products/

So in the web.config, there is the following: 所以在web.config中,有以下内容:

<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. 这是在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. 我试图将stopProcess属性设置为true ...这是我在几个线程中看到的解决方案,但没有任何工作。

This website is one of our legacy sites that uses an ISAPI module for Rewrites. 本网站是我们使用ISAPI模块进行重写的遗留站点之一。 Since we aren't using an Azure VM, we cannot continue using this method to rewrite. 由于我们不使用Azure VM,因此我们无法继续使用此方法进行重写。

Is there something I'm missing here? 这里有什么我想念的吗?

Azure Web Sites does not have the URL Rewrite module installed, so the config approach won't work. Azure网站没有安装URL重写模块,因此配置方法不起作用。 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 也许您可以更新站点代码以使用ASP.NET URL路由,如Scott Gu的博客文章所述: http//weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with -Asp网-4-web的表单-VS-2010-和净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 . Azure网站以前没有安装URL重写模块,但现在它已经安装,因此您可以在web.config使用标准的<system.webServer><rewrite>部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM