Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Recommended way to setup permanent redirects in Episerver 7.5

Vote:
 

Hi!

I need to setup some permanent redirecting in EPiServer 7.5, but what is the recommended approach? I have read Joel's article (http://joelabrahamsson.com/custom-routing-for-episerver-content/) about partial routing and segments and I was leaning towards using the segment-approach, but I am not sure it is the correct approach.

Creating an HTTPHandler could also be an option?

The urls looks similar to this:

/section/sectiontype/{old_url_with_parameters}

and the new url is:

/sectiontype/new/url/with/parameters

Basically, the parameters of the 'old url' have been turned into segments in the new url and the page to redirect to is placed differently in the page hierachy.

 

Does it make sense?

 

Best regards

Jesper

#80974
Feb 06, 2014 10:46
Vote:
 

I would suggest that you use routes.

Most of the time I think it's easier for you to determine your rules by code than to setup handlers in config.

#80983
Feb 06, 2014 13:21
Vote:
 

If this is an existing solution, you should also have SEO in mind - old urls should return 301 Moved Permanently.

#80984
Feb 06, 2014 13:46
Vote:
 

It is an existing site, so you are right Mari it should return a 301 moved permanently. 

 

Any suggestions on which approach to take? Is HttpHandler the correct way then?

#80999
Edited, Feb 06, 2014 15:57
Vote:
 
#81008
Edited, Feb 07, 2014 8:27
Vote:
 

You could also use the 404 module - see https://www.coderesort.com/p/epicode/wiki/404Handler

The module supports xml import of redirect rules in format:

<redirects>
   <urls>
       <url>
           <old>/templates/page.aspx?id=1234</old>
           <new>/travel</new>
       </url>
       <url>
...

    

#81009
Feb 07, 2014 8:44
Vote:
 

Thank you for the suggestions.

We are already using the 404-module, but in this case it is more than 1000 URLS that we need to remap, so I am not so keen on the xml import approach due to the risk of errors happening (typing). Additionally, I already got some code in place that can parse the old URL into an object, which should make it easier to map into the new URL.

#81041
Feb 07, 2014 13:05
Vote:
 

I ended up just adding a route and implemented an IRouteHandler, like:

RouteTable.Routes.Add("ROUTENAME", new Route("ROUTEURL", new IRouteHandlerImpl));

 

Where

ROUTENAME = name of route

ROUTEURL = url-pattern to match

new IRouteHandlerImpl = implementation of the interface IRouteHandler

#81285
Feb 13, 2014 11:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.