Legacy PHP urls do not invoke custom routing in MVC
asp.net-mvc, routes
Solution
Found the answer.
The problem is due to the fact that iis never starts the asp.net service if the extension is .php.
The solution is to go to Properties>Home Directory>Configuration, find the .php extension, change the executable path to the asp.net path, and limit it to "GET,HEAD,POST,DEBUG" or whatever you prefer. I originally selected the "All Verbs" radio button, but that did not work.
Though the page did not specifically have the answer I came up with, this page did help.
Problem
We recently replaced an old php website with an asp.net MVC website. In order to prevent 404 errors from the legacy urls in search engines, we setup a custom legacy route system via - http://www.mikesdotnetting.com/Article/108/Handling-Legacy-URLs-with-ASP.NET-MVC The code works on my local machine, and it redirects to the correct route; however, the live server issues a 404. Bonus problem/clue, the 404 is not our custom 404 page but the iis 6 default page. The code: ``` public class LegacyUrlRoute: RouteBase { // source: http://www.mikesdotnetting.com/Article/108/Handling-Legacy-URLs-with-ASP.NET-MVC public override RouteData GetRouteData(HttpContextBase httpContext) { const string status = "301 Moved Permanently"; var request = httpContext.Request; var response = httpContext.Response; var legacyUrl = request.Url.ToString(); var newUrl = ""; if (legacyUrl.Contains(".php")) { newUrl = "/"; if (legacyUrl.Contains("support/mailfilter.php")) newUrl = "/support/"; else if (legacyUrl.Contains("/support/default.php")) newUrl = "/support/"; else if (legacyUrl.Contains("/business/default.php")) newUrl = "/services/"; else if (legacyUrl.Contains("/residential/default.php")) newUrl = "/services/"; else if (legacyUrl.Contains("/about/default.php")) newUrl = "/home/about/"; else if (legacyUrl.Contains("/jobs.php")) newUrl = "/jobs/"; else if (legacyUrl.Contains("/support/links.php")) newUrl = "/support/"; else if (legacyUrl.Contains("/support/settings.php")) newUrl = "/support/"; else if (legacyUrl.Contains("/default.php")) newUrl = "/"; response.Status = status; response.RedirectLocation = newUrl; response.End(); } return null; } public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values) { return null; } } ``` Note: We suspect that the problem is with iis being unable to serve php pages, but I can't seem to find a setting in iis to fix the problem. It is as if the request never hits the Controller code, error or otherwise. All other pages/routing is working perfectly.