首页 > 解决方案 > .net 将旧的规范 url 重定向到新的 url 格式

问题描述

所以最近一位客户决定测试一个不同的规范网址,看看他们在搜索引擎上的位置是否发生了变化。当前的规范网址如下www.mydomain.com/{article-id},他们只想将 10 篇左右的文章更改为www.mydomain.com/{article-id}/{friendly-url}.

例子:www.mydomain.com/123456 -> www.mydomain.com/123456/the-gratest-article-ever

正如我所说,他们只想更改几篇文章,看看排名是否会发生变化。

为了正确测试排名是否增加,我必须创建一个从旧网址到新网址的永久重定向。

我曾尝试使用 httpRedirect 在 Web 配置中进行重定向,如下所示:

<location path="123456">
    <system.webServer>  
      <httpRedirect enabled="true" destination="/123456/the-gratest-article-ever" httpResponseStatus="Permanent" />
    </system.webServer>
 </location>

但这不起作用,因为它不断添加 /the-gratest-article-ever 一个又一个,整个事情都失败了The length of the URL for this request exceeds the configured maxUrlLength value.

是否可以使用网络配置来实现这一点?

谢谢,乙

标签: asp.neturlredirectweb-config

解决方案


推荐阅读