Then you have to do it in code by creating a filter and use it on application started.
ProductRedirectFilter.cs
public class ProductRedirectFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext.HttpContext.Request.Url.ToString().Contains("products"))
{
// find more efficient ways to check if url contains products
// use regex to check for string after products/..../.../
filterContext.Result = new RedirectResult("www.domain.com/products");
}
}
}
Add the filter in another class FilterConfig.cs
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new ProductRedirectFilter());
}
}
Then on your application started event handler:
public class YourApplication : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
}
}
Redirect all under a node
Hi,
I'm looking for a way to redirect all pages under a node without using the template page so for example opening
www.domain.com/products/car/volvo
will redirect to
www.domain.com/products
same with
www.domain.com/products/car
will redirect to
www.domain.com/products
Hi Philip,
Suppose content A needs to redirect to Content B.
In that case, you need to modify the document type of A and add new property: umbracoRedirect of type content picker.
Then on content A, you need to select content B on the redirect field. This will do a 302 redirect.
You can also use: umbracoInternalRedirectId of type content picker, this will not rewrite the url but will load content B.
See here for more reserved properties from Umbraco
But this will make admin have to put redirect from the cms to everything under the node. Is there no other way? Perhaps modifying the web config?
Then you have to do it in code by creating a filter and use it on application started.
ProductRedirectFilter.cs
Add the filter in another class FilterConfig.cs
Then on your application started event handler:
Not tested though, but should work.
will try and update tomorrow at work. Thanks!
is working on a reply...