ASP.NET MVC - 301重定向 - 搜索引擎优化问题

Jac*_*tti 1 asp.net-mvc seo iis-6 http-status-code-301

所以我有一个像这样的ActionName:

[ActionName("Chicago-Bears")]
public ActionResult ChicagoBears() {
  return View();
}
Run Code Online (Sandbox Code Playgroud)

谷歌的索引为:http://www.example.com/Teams/ChicagoBears

我坚持使用IIS6并且自己无法访问IIS.

当然,现在它有一个连字符.因此,如果有人点击该链接,Google会显示404.

如何在此实例中设置301重定向?我无法创建另一个名为ChicagoBears()的方法,所以......

多谢你们.

Bri*_*ian 5

为Teams/ChicagoBears创建一个路径,指向一个提供永久重定向的操作.

在Global.asax中......

routes.MapRoute("ChicagoBearsRedirect",
    "Teams/ChicagoBears",
    new { controller = "Teams", action = "RedirectChicagoBears" }
);
Run Code Online (Sandbox Code Playgroud)

在TeamsController中......

public ActionResult RedirectChicagoBears()
{
    return RedirectToActionPermanent("Chicago-Bears");
}
Run Code Online (Sandbox Code Playgroud)