I'm trying to develop a custom route for this use case.
The following URL patterns:
https://example.com/new/Brand-1/product-1.htm
https://example.com/used/Brand-2/product-2.htm
should be redirected to https://example.com/products
The Brand
& Product
names in the URL may change, but the relative root will always be either /new
or /used
.
When I browse this URL - https://example.com/used/mybrand/myproduct.htm, it throws the error:
Here is the code:
RouteConfig.cs:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("OldUsed", "used/{make}/{name}", new
{
controller = "RedirectToListing",
action = "RedirectOldVdpToVlp",
make = "",
name=""
});
}
}
InitializeRoutes.cs:
public class InitializeRoutes : Sitecore.Mvc.Pipelines.Loader.InitializeRoutes
{
public override void Process(PipelineArgs args)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
z_Feature.Base.Pipelines.config:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<initialize>
<processor type="Feature.Base.Pipelines.InitializeRoutes, Feature.Base" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
</initialize>
</pipelines>
</sitecore>
</configuration>
Is this the right way.
Allowed extensions
in<processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
? If this is not done Sitecore will not runhttpRequestBegin
pipeline