When running DD4T on my local development machine I can access the pages that I have published.
- www.mywebsite.com - Works
- www.mywebsite.com/index.html - Works
- www.mywebsite.com/aboutme.html - Works
When I deploy my website to the server, I can only access www.mywebsite.com as soon as I put index.html at the end I recieve a 404.
- www.mywebsite.com - Works
- www.mywebsite.com/index.html - Does not work
- www.mywebsite.com/aboutme.html - Does not work
In the event logs I don't see any other then the 404 and the Tridion logs on debug only say 404 can't find page index.html or aboutme.html In the web.config I can change the default page to aboutme.html that works but again if I go to it directly www.mywebsite.com/aboutme.html I recieve the 404.
When I create a helloworld.html on the server I am able to get that page without receiving any errors.
PageController:
public class PageController : TridionControllerBase
{
public override ActionResult Page(string pageId)
{
try
{
pageId = UriHelper.ParseUrl(pageId);
return base.Page(pageId);
}
catch (Exception)
{
return PageNotFound();
}
}
private ActionResult PageNotFound()
{
Response.StatusCode = 404;
Response.TrySkipIisCustomErrors = true;
return base.Page("ErrorPage404.html");
}
}
RouteConfig:
/* Route: TridionPage
* Default route that being used for all Tridion pages.
*/
routes.MapRoute(
name: "TridionPage",
url: "{*PageId}",
defaults: new { controller = "Page", action = "Page", id = UrlParameter.Optional },
constraints: new { pageId = @"^(.*)?$" }
);
/* Route: Default
* Overwritten the "Default" towards the TridionPage Route, this will then return a nice404.
*/
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Page", action = "Page", id = UrlParameter.Optional }
);