Not in any easy way I think.
Best way I think is to listen for ContentRouted event from EPiServer.Web.Routing.ContentRoute.
Then check if the routed content is actually a shortcut to another page and then directly do a Redirect with 302 status.
Since you are modifying core routing that will trigger for every page, be extra careful :)
I've made an IInitializableModule.
The problem is that viewing a page on the website do not fire RoutedContent ( It seems it triggers the shortcut page instead)
The page with a shortcut is redirected and the page redirected triggers the code bellow. It works great in Editmode but I need it to work on the website.
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class RedirectRoutingConfig : IInitializableModule { public void Initialize(InitializationEngine context) { EPiServer.Web.Routing.ContentRoute.RoutedContent += ContentRoute_RoutingContent; } public void Uninitialize(InitializationEngine context) { } public void Preload(string[] parameters) { } private void ContentRoute_RoutingContent(object sender, EPiServer.Web.Routing.RoutingEventArgs e) { var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>(); var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>(); PageData contentData; if (!contentLoader.TryGet(e.RoutingSegmentContext.RoutedContentLink, out contentData)) return; if (!PageEditing.PageIsInEditMode) { if (contentData.LinkType == PageShortcutType.Shortcut) { var shortcutPageId = contentData["PageshortcutLink"].ToString(); if (string.IsNullOrEmpty(shortcutPageId)) return; var shortcutContentReference = new ContentReference(shortcutPageId); e.RoutingSegmentContext.TemporaryRedirect(urlResolver.GetUrl(shortcutContentReference)); } } } }
How can I get hold of the request before the page is redirected? Thats the request I need to set to TemporaryRedirect()
I'm redirecting some pages to another pages in EPiServer. I'm using the option 'Redirect to another EPiServer page' in the 'All properties' setting panel. While investigating the network tab in the web browser console I can see the pages are getting HTTP301.
My goal is to give the pages the HTTP302 because the pages are Temporarily moved.
Any good idea on how I can achieve that?