如何避免与 routes.MapRpute 重复?

问题描述 投票:0回答:0

这是我在 RouteConfig.cs 中的路线

routes.MapRoute(
  name: "ComputerSearch",
  url: "eq",
  defaults: new { controller = "Computer", action = "Search", ID = UrlParameter.Optional },
  namespaces: new[] { "Pixel.Inforworld.Website.Controllers" }
);

到目前为止,它与这样的 URL 配合得很好

https://mywebsite.com/eq?cat=intel

然而,这个网址也是存在的

https://mywebsite.com/Computer/Search?cat=intel

上面的两个网址给出了相同的内容,实际上是同一个页面,Google Search Console 将我的网站标记为

Page is not indexed: Duplicate, Google chose different canonical than user

这是我的首选网址

https://mywebsite.com/eq?cat=intel

所以问题是,如何禁用或使 /Computer/Search/ 消失?

c# .net asp.net-mvc-4 model-view-controller
© www.soinside.com 2019 - 2024. All rights reserved.