繁体   English   中英

如何通过IIS从URL上删除Index.html

[英]How to cosmetically remove Index.html from URL with IIS

我们有一个维护ASP.NET MVC站点,我们将该站点部署到Azure中的维护部署插槽以进行快速交换。 现在,该站点是静态html + Global.asax中的一行试图将所有请求重定向到Index.html

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        Response.Redirect("/Index.html");
    }

现在可以使用,但是当用户重定向到维护页面时,会在URL中看到Index.html。 我想通过IIS Url Rewrite规则彻底删除它。 我认为,如何通过“重写”操作来实现此目的。

您可以通过不同的方式实现它:

  1. 在global.asax中使用rewritepath 您可以在这里找到更多详细信息: https : //www.dotnetperls.com/rewritepath

  2. 带有IIS URL重写模块。 您需要安装它 ,然后在您的web.config中添加以下重写规则:

    <rule name="Rewrite index.html" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="/index.html" /> </rule>规则会将所有请求重写为index.html

暂无
暂无

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

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