在我的網站上,我將一些圖片從一個文件夾移到另一個文件夾。使用ASP.NET MVC重定向MapRoute
現在,當我收到舊圖像的攝影請求「/ old_folder /圖片/ *」我想打一個永久重定向到新的文件夾,這些圖片「/ new_folder /圖片/ *」
例如:
/old_folder/images/image1.png => /new_folder/images/image1.png
/old_folder/images/image2.jpg => /new_folder/images/image2.jpg
我添加了一個簡單的重定向控制器
public class RedirectController : Controller
{
public ActionResult Index(string path)
{
return RedirectPermanent(path);
}
}
現在我需要設置正確的路由,但我不知道如何傳遞路徑部分的路徑參數。
routes.MapRoute("ImagesFix", "/old_folder/images/{*pathInfo}", new { controller = "Redirect", action = "Index", path="/upload/images/????" });
感謝
你應該張貼此作爲評論 –