繁体   English   中英

ASP.NET URL重写并将旧URL标记为301

[英]ASP.NET URL rewriting and tag the old URL to 301

嗨,我正在尝试将我的网址:www.mydomain.com/hw/Index.aspx重写为www.mydomain.com/hello-world/index.aspx。 这是我在web.config中的代码:

    <rule name="Redirect to WWW" stopProcessing="true">
      <match url="^hello-world/index.aspx" />
      <action type="rewrite" url="hw/Index.aspx" />
    </rule> 

问题是我在同一个页面上有两个网址。

  1. www.mydomain.com/hw/Index.aspx
  2. www.mydomain.com/hello-world/index.aspx

我想做的是,当用户浏览www.mydomain.com/hw/Index.aspx时 ,它将被标记为301,并将重定向到www.mydomain.com/hello-world/index.aspx

请帮我。

提前致谢。

rewrite实质上使IIS为用户提供相同的页面,它在内部重写URL并将其传递给您的应用程序。

另一方面, rewrite实际上将响应发送给客户端,表明请求的资源已移动(即301)

要解决此问题,请将操作类型从rewrite更改为redirect

<rule name="Redirect to WWW" stopProcessing="true">
  <match url="^hello-world/index.aspx" />
  <action type="redirect" url="hw/Index.aspx" />
</rule> 

暂无
暂无

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

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